#include <cstdio>
#include <iostream>
using namespace std;
int a[100000];
int b[100000];
int main()
{
freopen("E.in","r",stdin);
freopen("E.out","w",stdout);
int n,m;
int k;
cin>>n;
cin>>m;
for (int i=0;i<n;i++)
{
cin>>a[i];
}
for (int i=0;i<m;i++)
{
cin>>b[i];
}
int s=0;
if (n>m)
{
sort(a,a+n);
sort(b,b+m);
reverse(b,b+m);
for (int i=0;i<m;i++)
{
s+=a[i]*b[i];
}
cout<<m;
cout<<" "<<s;
return 0;
}
sort(a,a+n);
reverse(a,a+n);
sort(b,b+m);
s=0;
for (int i=0;i<n;i++)
{
s+=a[i]*b[i];
}
cout<<n;
cout<<" "<<s;
return 0;


}