var
  a,b: array [0..100010] of int64;
  c: array [0..1010] of longint;
  ans:int64;
  i,j,n,m:longint;

function min(a,b:longint):longint;
begin
  if a>b then min:=b else min:=a;
end;

begin
  assign(input,'e.in');
  reset(input);
  assign(output,'e.out');
  rewrite(output);
  read(n,m);
  write(min(n,m),' ');
  for i:=1 to n do read(a[i]);
  for i:=1 to m do read(b[i]);
  fillchar(c,sizeof(c),0);
  for i:=1 to n do inc(c[a[i]]);
  n:=0;
  for i:=1 to 1000 do 
    for j:=1 to c[i] do begin
      inc(n);
      a[n]:=i;
    end;      
  fillchar(c,sizeof(c),0);
  for i:=1 to m do inc(c[b[i]]);
  m:=0;
  for i:=1 to 1000 do 
    for j:=1 to c[i] do begin
      inc(m);
      b[m]:=i;
    end;
  n:=min(n,m);     
  ans:=0;
  for i:=1 to n do 
    ans:=ans+a[i]*b[n-i+1];
  writeln(ans);
  close(output);
end.
