#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

#define PROB "E"
#define VI vector<int>

using namespace std;

int main() {
  freopen(PROB".in", "r", stdin);
  freopen(PROB".out", "w", stdout);
  int i,N,M,p;
  long long ans=0;
  cin >> N >> M;
  VI a(N),b(M);
  for(i=0;i<N;i++) cin >> a[i];
  for(i=0;i<M;i++) cin >> b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if( N > M ) {
    p = M;
    for(i=0;i<M;i++) {
      ans += (long long)((long long)a[i] * (long long)b[M-i-1]);
    }
  }
  else {
    p = N;
    for(i=0;i<N;i++) {
      ans += (long long)((long long)b[i] * (long long)a[N-i-1]);
    }
  }
  cout << p << " " << ans;
  return 0;
}
