#include <iostream>
//#include <stdio>


using namespace std;

int a[100005];
int b[100005];

void Sorta(int l,int r) 
	{
	  int i=l; int j=r;
	   int x=a[(i+j)/2];
	   do 
	   {
		 while (x>a[i]) i++;
		 while (x<a[j]) j--;
		  if (i<=j) 
		  {
			int t=a[i];
			a[i]=a[j]; a[j]=t;
			i++; j--;
		  }
		   
		   
	   }while(i<j);
	   if (i<r) Sorta(i,r);
	   if (j>l) Sorta(l,j);
	}
void Sortb(int l,int r) 
	{
	  int i=l; int j=r;
	   int x=b[(i+j)/2];
	   do 
	   {
		 while (x>b[i]) i++;
		 while (x<b[j]) j--;
		  if (i<=j) 
		  {
			int t=b[i];
			b[i]=b[j]; b[j]=t;
			i++; j--;
		  }
		   
		   
	   }while(i<j);
	   if (i<r) Sortb(i,r);
	   if (j>l) Sortb(l,j);
	}
         int main()
{
freopen("E.in","r",stdin);
freopen("E.out","w",stdout);
int n,m,i;
cin>>n>>m;
 for (i=0;i<n;i++) 
 cin>>a[i];
 for (i=0;i<m;i++) 
  cin>>b[i];
Sorta(0,n-1);
Sortb(0,m-1);
/*for (i=0;i<n;i++) 
  cout<<a[i]<<" ";
 cout<<endl;
for (i=0;i<m;i++) 
  cout<<b[i]<<" ";
cout<<endl;*/
int mi;
 if (n>m) mi=m; else mi=n;

long long s=0,s1=0;
 for (i=0;i<mi;i++)
   s+=a[i]*b[mi-i-1];
 for (i=0;i<mi;i++)
   s1+=b[i]*a[mi-i-1];
 cout<<mi<<" ";
 if (s<s1) cout<<s; else cout<<s1;

return 0;
}
