uses
  SysUtils;

var
  i,j,k,s:longint;
  m,n:longint;
  a,b:array[1..1000]of longint;
  x,z:array[1..10000] of longint;
begin
  assign(input,'E.in');
  reset(input);
  assign(output,'E.out');
  rewrite(output);
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  readln(n,m);

  if m<n then k:=m else k:=n;
  for i:=1 to n do
    begin
      read(j);
      inc(a[j]);
    end;
  for i:=1 to m do
    begin
      read(j);
      inc(b[j]);
    end;
  s:=0;
  j:=0;
    for i:=1 to 1000 do
      if j<=k then
      for n:=1 to a[i] do
        begin
            inc(j);
           x[j]:=i;
        end;
  j:=0;
    for i:=1 to 1000 do
      if j<=k then
      for n:=1 to b[i] do
        begin
          inc(j);
          z[j]:=i;
        end;
  for i:=1 to k do
    s:=s+z[i]*x[k-i+1];

   write(k,' ',s);

  close(input);
  close(output);
end.

