var a,a2:array[0..100001] of longint;
    b,b2:array[0..100001]of longint;
    i,j,n,m,k,min,sum1,sum2,min2:longint;
Begin
assign(input,'E.in');reset(input);
assign(output,'E.out');rewrite(output);
readln(n,m);
for i:=1 to n do begin read(k);a[k]:=a[k]+1;end;readln;
for i:=1 to m do begin read(k);b[k]:=b[k]+1;end;
if n>m then min:=m else min:=n;
i:=100000;j:=0;a2:=a;b2:=b;

write(min);min2:=min;
while (min>0) do
begin
if a[i]=0 then i:=i-1 else begin
                           a[i]:=a[i]-1;
                           min:=min-1;
                           while (b[j]=0)and(j<100001) do j:=j+1;
                           b[j]:=b[j]-1;
                           if j=100001 then else sum1:=sum1+i*j;
                           end;
end;
i:=0;j:=100000;
while (min2>0) do
begin
if a2[i]=0 then i:=i+1 else begin
                           a2[i]:=a2[i]-1;
                           min2:=min2-1;
                           while (b2[j]=0)and(j>0) do j:=j-1;
                           b2[j]:=b2[j]-1;
                           sum2:=sum2+i*j;
                           end;
end;
if sum1>sum2 then sum1:=sum2;

writeln(' ',sum1);
close(input);close(output);
end.