import java.io.*;
import java.util.*;

public class Main
{
   public static void main(String[] args) throws IOException {
      Scanner in = new Scanner(new FileReader("E.in"));
      PrintWriter out = new PrintWriter(new FileWriter("E.out"),true);
int n=in.nextInt();
int m=in.nextInt();
int x;
if(n>=m)x=m; else x=n;
int a[]=new int[n];
int b[]=new int[m];
for(int i=0; i<n; i++){
a[i]=in.nextInt();
}

for(int i=0; i<m; i++){
b[i]=in.nextInt();
}

Arrays.sort(a);
Arrays.sort(b);

long sum=0;
for(int i=0; i<x; i++){
sum=sum+a[i]*b[x-i-1];
}

out.println(x+" "+sum);
}
}