program e;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  var
  n,m:longint;
  a:array[1..100000] of longint;
  b:array[1..100000] of longint;
  i,j:longint;
  buf,s:longint;
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 i:=1 to m do
  read(b[i]);
  for i:=1 to n-1 do
  for j:=1 to n-1 do
  if a[j]>a[j+1] then
  begin
  buf:=a[j];
  a[j]:=a[j+1];
  a[j+1]:=buf;
  end;
  for i:=1 to m-1 do
  for j:=1 to m-1 do
  if b[j]>b[j+1] then
  begin
  buf:=b[j];
  b[j]:=b[j+1];
  b[j+1]:=buf;
  end;
  if (n<m) then
  begin
  s:=0;
  for i:=1 to n do
  s:=s+a[i]*b[n-i+1];
  write(n,' ',s);
  end
  else
  begin
  s:=0;
  for i:=1 to m do
  s:=s+b[i]*a[m-i+1];
  write(m,' ',s);
  end;
  close(output);
  end.
