program abc(input,output);
var n,m,i,j,k:longint;
a,b:array [1..1000] of longint;
begin
assign(input, 'E.in');
assign(output, 'E.out');
reset (input);
rewrite (output);
read (input, n, m);
if (m>100000) or (n>100000) then
   begin
   write (output, 'Constant is out of range.');
   close (input);
   close (output);
   exit;
   end;
readln (input);
for i:=1 to n do
    read (input, a[i]);
readln (input);
for i:=1 to m do
    read (input, b[i]);

for j:=1 to n do
for i:=1 to n-1 do
    if a[i]>a[i+1] then
       begin
       k:=a[i];
       a[i]:=a[i+1];
       a[i+1]:=k;
       end;
for j:=1 to m do
for i:=1 to m-1 do
    if b[i]>b[i+1] then
       begin
       k:=b[i];
       b[i]:=b[i+1];
       b[i+1]:=k;
       end;
if n>m then n:=m;
write (output, n, ' ');
k:=0;
for i:=1 to n do
    begin
    k:=k+a[i]*b[n+1-i];
    end;
writeln(output,k);
close (input);
close (output);
end.