var n,m:integer;
   an,am:array [1..100000] of integer;
   i,j,buf,res:integer;

begin
    assign(input,'E.in');
    reset(input);
    assign(output,'E.out');
    rewrite(output);

    readln(n,m);
    for i:=1 to n do read(an[i]);
    for i:=1 to m do read(am[i]);

    for i:=1 to n do
       for j:=1 to n-1 do
          if an[j]>an[j+1] then begin
             buf:=an[j];
             an[j]:=an[j+1];
             an[j+1]:=buf;
             end;
    res:=0;
    for i:=1 to m do
       for j:=1 to m-1 do
          if am[j]<am[j+1] then begin
             buf:=am[j];
             am[j]:=am[j+1];
             am[j+1]:=buf;
          end;

    if m>n then begin
    for i:=1 to n do res:=res+an[i]*am[i];
    write(n,' ',res) end
    else begin
       for i:=1 to m do res:=res+an[i]*am[i];
       write(m,' ',res);
    end;


    close(output);
end.
