
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>

#define  max_n    (int)1e5
#define  min(x,y) ((x)<(y)?(x):(y))

using namespace std;

int n, m;
int a[max_n], b[max_n];

int init_prg() {
   scanf("%d%d", &n,&m);
   for (int i = 0; i < n; ++i)
      scanf("%d", &a[i]);
   for (int i = 0; i < m; ++i)
      scanf("%d", &b[i]);
   return 0;
}

int main() {

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

   init_prg();

   int sz = min(n,m);

   long long rez1 = 0;

   sort(a,a+n);
   sort(b,b+m,greater<int>());

   for (int i = 0; i < sz; ++i)
      rez1 += a[i]*b[i];

   long long rez2 = 0;

   sort(a,a+n,greater<int>());
   sort(b,b+m);

   for (int i = 0; i < sz; ++i)
      rez2 += a[i]*b[i];

   long long rez3 = 0;

   sort(a,a+n);
   sort(b,b+m);

   for (int i = 0; i < sz; ++i)
      rez3 += a[i]*b[i];

   cout << sz << " " << min(min(rez1,rez2),rez3);
   
   return 0;
}
