#include <cstdio>
#include <iostream>
#include <utility>
#include <cassert>
#include <algorithm>

using namespace std;

#define problem "C"

const int MAXN = 1000;
const int MAXM = 1000;
const int MAXC = 1000;

int a[MAXN];
int b[MAXN];

int main() {
//	freopen(problem".in", "r", stdin);
//	freopen(problem".out", "w", stdout);
	
	int n, m; scanf("%d %d", &n, &m);
	assert((1 <= n) && (n <= MAXN) && (1 <= m) && (m <= MAXM));
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		assert((1 <= a[i]) && (a[i] <= MAXC));
	}
	for (int i = 0; i < m; ++i) {
		scanf("%d", &b[i]);
		assert((1 <= b[i]) && (b[i] <= MAXC));
	}
	
	sort(a, a + n, greater<int>());
	sort(b, b + m, greater<int>());
	
	n = min(n, m);
	
	int result = 0;
	for (int i = 0; i < n; ++i) {
		result += a[i] * b[i];
	}
	
	printf("%d %d\n", n, result);
	
	return 0;
}
