var k,l:array[1..100000] of longint ;
n,m,i,j,x,s:longint;
begin
assign(input,'E.in');
reset(input);
assign(output,'E.out');
rewrite(output);
readln(input,n,m);
for i:=1 to n do read(input,k[i]);
readln(input);
for i:=1 to m do read(input,l[i]);
if n>m then  begin
for i:= 1 to n do
for j:= i to n do
if k[i]>k[j] then begin x:=k[i]; k[i]:= k[j]; k[j]:=x;  end;
for i:= 1 to m do
for j:= i to m do
if l[i]<l[j] then begin x:=l[i]; l[i]:= l[j]; l[j]:=x;  end;
for i:= 1 to m do s:= s+k[i]*l[i];writeln(output,m,' ',s);

end
else begin
for i:= 1 to n do
for j:= i to n do
if k[i]<k[j] then begin x:=k[i]; k[i]:= k[j]; k[j]:=x;  end;
for i:= 1 to m do
for j:= i to m do
if l[i]>l[j] then begin x:=l[i]; l[i]:= l[j]; l[j]:=x;  end;
for i:= 1 to n do s:= s+k[i]*l[i];
writeln(output,n,' ',s);
 end;
close(output);
end.






