const   filein='E.in';
        fileout='E.out';

var i,j,k,l,m,n         :integer;
    sum                 :int64;
    a,b                 :array[1..100000] of integer;
procedure readf;
begin
 assign(input,filein);
 reset(input);
  read(n,m);
 for i:=1 to n do
  read(a[i]);
 readln;
 for i:=1 to m do
  read(b[i]);
 close(input);
end;

procedure qsort(var mas:array of integer; ilo,ihi:integer);
var
 lo,hi,p,t:integer;
begin
 lo:=ilo;
 hi:=ihi;
 p:=mas[(lo+hi)div 2];
 repeat
  while mas[lo]<p do inc(lo);
  while mas[hi]>p do dec(hi);
  if lo<=hi then begin
   t:=mas[lo];
   mas[lo]:=mas[hi];
   mas[hi]:=t;
   inc(lo);
   dec(hi);
  end;
 until lo>hi;
 if hi>ilo then qsort(mas,ilo-1,hi);
 if lo<ihi then qsort(mas,lo,ihi-1);
end;




procedure main;
begin
 qsort(a,0,n-1);
 qsort(b,0,m-1);
 if n>m then
  n:=m;
 for i:=1 to n do
  sum:=sum+a[n-i+1]*b[i];
end;


procedure vivod;
begin
 assign(output,fileout);
 rewrite(output);
  write(n,' ',sum);
 close(output);
end;

begin
 readf;
 main;
 vivod;
end. 
