#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main(){

  freopen("E.in", "r", stdin); 
  freopen("E.out", "w", stdout);

  int n,m,tmp;

  cin >> n >> m;

  multiset<int> a;
  multiset<int> b;
 
  int num = min(n, m);
  
  for(int i = 0; i < n; i++)
  {
    cin >> tmp;
    a.insert(tmp);
  }
  
  for(int i = 0; i < m; i++)
  {
    cin >> tmp;
    b.insert(tmp);
  }

  
  int sum = 0;
  vector <int> a1(a.size());
  vector <int> b1(b.size());

  copy(a.begin(), a.end(), a1.begin());
  copy(b.begin(), b.end(), b1.begin());
  
  for(int i = 0; i < num; i++){
     sum += b1[num - i - 1]*a1[i];  
  }

  cout << num <<" "<< sum << endl;

  return 0;
}
