{$APPTYPE CONSOLE}

uses
  SysUtils;

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