var
A : array[1..1000000] of longint;
B: array [1..1000000] of longint;
e,n,m,i,j,min,Sum:longint;
f:text;
begin
assign(f,'E.in');
reset(f);
readln(f,n,m);
for i:=1 to n do read(f,a[i]);
readln(f);
for i:=1 to m do read(f,b[i]);
close(f);
sum:=0;
for i:=1 to n-1 do
for j:=i+1 to n do
begin
if (a[i]>a[j]) then
begin
min:=a[j];
a[j]:=a[i];
a[i]:=min;
end;
end;
for i:=1 to m-1 do
for j:=i+1 to m do
begin
if (b[i]>b[j]) then
begin
min:=b[j];
b[j]:=b[i];
b[i]:=min;
end;
end;
if (n>=m) then e:=m else e:=n;
for i:=1 to e do
begin
Sum:= Sum + a[i]*b[e-i+1];
end;
assign(f,'E.out');
rewrite(f);
writeln(f,e,' ',Sum);
close(f);
 { TODO -oUser -cConsole Main : Insert code here }

end.
