#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#define min(a,b) ((a>b)?b:a)
#define max(a,b) ((a>b)?a:b)
bool op(int a,int b) 
{return ((a>b)?1:0);}
using namespace std;
int a[10001];
int b[10001];
int main()
{
freopen("E.in","r",stdin);
freopen("E.out","w",stdout);
int m,n;
long long sum=0;
cin >> n >> m;
for (int i=0;i<n;i++) scanf("%d",&a[i]);
for (int i=0;i<m;i++) scanf("%d",&b[i]);
if (m<n) 
{
sort(a,a+n);
sort(b,b+m,op);         
for (int i=0;i<m;i++) sum+=b[i]*a[i];
cout << m << " " << sum;
return 0;
}
sort(a,a+n,op);
sort(b,b+m);         
for (int i=0;i<n;i++) sum+=b[i]*a[i];
cout << n << " " << sum;


return 0;
}

