program Project2;

{$APPTYPE CONSOLE}

var
  f1,f2: textfile;
  i,j,m,n,tmp:integer;
  a,b: array[1..100000] of integer;
  s: int64;
begin
  assignfile(f1,'E.in');
  assignfile(f2,'E.out');
  reset(f1);
  rewrite(f2);
  readln(f1,n,m);
  for i:=1 to n do
  begin
    read(f1,a[i]);
  end;
//  readln(f1,a[i+1]);
  for i:=1 to m do
  begin
    read(f1,b[i]);
  end;
  if n<m then
  begin
    for i:=1 to n do
    begin
      for j:=1 to n do
      begin
        if a[i]>a[j] then
        begin
          tmp:=a[i];
          a[i]:=a[j];
          a[j]:=tmp;
        end;
      end;
    end;
    for i:=1 to m do
    begin
      for j:=1 to m do
      begin
        if b[i]<b[j] then
        begin
          tmp:=b[i];
          b[i]:=b[j];
          b[j]:=tmp;
        end;
      end;
    end;
  end
  else begin
    for i:=1 to n do
    begin
      for j:=1 to n do
      begin
        if a[i]<a[j] then
        begin
          tmp:=a[i];
          a[i]:=a[j];
          a[j]:=tmp;
        end;
      end;
    end;
    for i:=1 to m do
    begin
      for j:=1 to m do
      begin
        if b[i]>b[j] then
        begin
          tmp:=b[i];
          b[i]:=b[j];
          b[j]:=tmp;
        end;
      end;
    end;
  end;
  if m<n then n:=m;
  s:=0;
  for i:=1 to n do
  begin
    a[i]:=a[i]*b[i];
    s:=s+a[i];
  end;
  writeln(f2,n,' ',s);
  closefile(f1);
  closefile(f2);
end.
