program Main;

{$APPTYPE CONSOLE}

uses
  SysUtils;
VAR min,max,n,m,c:longint;
    masb,masm:array [1..100000] of integer;
    res:int64;
procedure readm;
var i,j:longint;
begin
  if n>m then begin c:=1;min:=m;max:=n end
     else if n<m then begin c:=2;min:=n;max:=m end
          else begin c:=3;min:=m; max:=n end;

  case c of
  1: begin
      for i:=1 to max do read(masb[i]);
      for i:=1 to min do read(masm[i]);

    end;
  2: begin
      for i:=1 to min do read(masm[i]);
      for i:=1 to max do read(masb[i]);

    end;
  3: begin
      for i:=1 to min do read(masm[i]);
      for i:=1 to max do read(masb[i]);
    end;
  end;

end;

procedure sort;
var i,j,c:longint;
begin
for i:=1 to min-1 do
  for j:=i to min do
  begin
    if masm[i]<masm[j] then
       begin
         c:=masm[i];
         masm[i]:=masm[j];
         masm[j]:=c;
       end;
  end;

for i:=1 to max-1 do
  for j:=i to max do
  begin
    if masb[i]>masb[j] then
       begin
         c:=masb[i];
         masb[i]:=masb[j];
         masb[j]:=c;
       end;
  end;


end;

procedure lkjdfg;
var i:longint;
begin
res:=0;
for i:=1 to min do
begin
res:=res+(masm[i]*masb[i]);
end;

end;

BEGIN
  assign(input,'e.in');
  reset(input);
  assign(output,'e.out');
  rewrite(output);
  readln(n,m);
  readm;
  sort;
  lkjdfg;
  write(min,' ',res);
  close(output);
END.
