#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int a[100010], b[100010];
int n, m;
long long ans;

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

  cin >> n >> m;

  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  
  sort(a, a + n);
  sort(b, b + m);

  n = min(n, m);

  for (int i = 0; i < n; i++)
    ans+=a[i] * b[n - i - 1];

  cout << n << " " << ans;
  return 0;
}
