program Main;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  filein : textfile;
  fileout : textfile;
  N,M,i : integer;
  MassN : array of integer;
  MassM : array of integer;
  amount : longint;
  
procedure sort_N(nap:byte); //  0 - down   other digit - up
var
  i,j,tmp:integer;
begin
if nap = 0 then

  begin
  for i:=1 to N-1 do
    for j:=1 to N-i do
      if MassN[j]<MassN[j+1] then
        begin
        tmp := MassN[j];
        MassN[j] := MassN[j+1];
        MassN[j+1] := tmp;
        end;
  end

          else

  begin
  for i:=1 to N-1 do
    for j:=1 to N-i do
      if MassN[j]>MassN[j+1] then
        begin
        tmp := MassN[j];
        MassN[j] := MassN[j+1];
        MassN[j+1] := tmp;
        end;
  end;

end;


procedure sort_M(nap:byte); //  0 - down   other digit - up
var
  i,j,tmp:integer;
begin
if nap = 0 then

  begin
  for i:=1 to M-1 do
    for j:=1 to M-i do
      if MassM[j]<MassM[j+1] then
        begin
        tmp := MassM[j];
        MassM[j] := MassM[j+1];
        MassM[j+1] := tmp;
        end;
  end

          else

  begin
  for i:=1 to M-1 do
    for j:=1 to M-i do
      if MassM[j]>MassM[j+1] then
        begin
        tmp := MassM[j];
        MassM[j] := MassM[j+1];
        MassM[j+1] := tmp;
        end;
  end;

end;


begin
  assignfile(filein,'E.in');
  reset(filein);

  readln(filein,N,M);
  setlength(MassN,N+1);
  setlength(MassM,M+1);

  for i:=1 to N do
    read(filein,MassN[i]);
  for i:=1 to M do
    read(filein,MassM[i]);

  if N = M then
    begin
    sort_N(0);
    sort_M(1);
    end
  else if N > M then
    begin
    sort_N(1);
    sort_M(0);
    end
  else if N < M then
    begin
    sort_N(0);
    sort_M(1);
    end;

  amount := 0;
  if (N > M) then N := M;
  for i:=1 to N do
    amount := amount + (MassN[i] * MassM[i]);

  close(filein);

  assignfile(fileout,'E.out');
  rewrite(fileout);
  writeln(fileout,N,' ',amount);
  close(fileout);
end.
