var n,m,k,i,j,p,l,t,r:longint;
    a,b:array[1..100] of longint;
procedure qsort(l,r:longint);
   var x,y,i,j:longint;
    begin
      i:=l; j:=r;
       x:=a[(l+r) div 2];
        repeat
         while a[i]<x do inc(i);
         while a[j]>x do dec(j);
          if i<=j then begin
                       y:=a[i];
                       a[i]:=a[j];
 		       a[j]:=y;
                       inc(i);
                       dec(j);
                       end;
         until i>j;
          if i<r then qsort(i,r);
          if l<j then qsort(l,j);
      end;
procedure qsort1(l,r:longint);
   var x,y,i,j:longint;
    begin
      i:=l; j:=r;
       x:=b[(l+r) div 2];
        repeat
         while b[i]<x do inc(i);
         while b[j]>x do dec(j);
          if i<=j then begin
                       y:=b[i];
                       b[i]:=b[j];
 		       b[j]:=y;
                       inc(i);
                       dec(j);
                       end;
         until i>j;
          if i<r then qsort(i,r);
          if l<j then qsort(l,j);
      end;


begin
 assign(input,'E.in'); reset(input);
 assign(output,'E.out'); rewrite(output);
 read(n,m);   p:=0; l:=0; t:=0;
 for i:=1 to n do
 read(a[i]);
qsort(1,n);
 for j:=1 to m do
 read(b[j]);
qsort1(1,m);   
  if (n>=m) then k:=n-(n mod m);
  if (n<=m) then k:=m-(m mod n);
  if (n=1) or (m=1) then k:=1;
 if (n>m) then begin
   for i:=1 to k do
   for j:=k downto 1 do begin
   p:=p+(a[i]*b[j]);
   if (i=j) then t:=t+(a[i]*b[j]);
  end;
end;
 if (n<m) then begin
   for i:=k downto 1 do
   for j:=1 to k do begin
   p:=p+(a[i]*b[j]);
  if (i=j) then t:=t+(a[i]*b[j]);
 end;
 end;
 if (n=1) or (k=1) then 
 l:=a[1]*b[1] 
 else l:=p-t;
 write(k,' ',l);
 close(output);
end.

