type mass=array[1..1000] of longint;
var x,k,q,n,m,i,s:longint;
    a,b:mass;
Begin 
assign(input,'e.in');
assign(output,'e.out');
reset(input);
read(n,m);
For i:=1 to n do
   read(a[i]);
For i:=1 to m do
   read(b[i]);
rewrite(output);
if n<m then x:=n else x:=m;
repeat
k:=0;
for i:=1 to n-1 do 
   If a[i]>a[i+1] then begin   
      q:=a[i];
      a[i]:=a[i+1];
      a[i+1]:=q;
      k:=1;
   end;
until k=0;
repeat
k:=0;
for i:=1 to m-1 do
   If b[i]>b[i+1] then begin
      q:=b[i];
      b[i]:=b[i+1];
      b[i+1]:=q;
      k:=1;
   end;
until k=0;
s:=0;       
for i:=1 to x do
s:=s+(a[i]*b[x+1-i]);
write(x,' ',s);
close(input);
close(output);
end.
       
    
 
