#include using namespace std; /* * */ int main() { int n, m,wb = 0,bb = 0; cin >> n >> m; int w[50000][2]; int b[50000][2]; for (int i = 0;i < n/2 ; i++) { cin >> w[i][0] >> w[i][1]; } for (int i = 0;i < n/2 ; i++) { cin >> b[i][0] >> b[i][1]; } int ok = 1; while(ok) { ok = 0; for(int i = 0; i< n/2;i++) for(int j = 0; j< n/2;j++) if(w[i][0] < b[j][0]) { int aux = w[i][0]; w[i][0] = b[j][0]; b[j][0] = aux; aux = w[i][1]; w[i][1] = b[j][1]; b[j][1] = aux; ok = 1; } } for (int i = 0;i < n/2 ; i++) wb += w[i][0]; for (int i = 0;i < n/2 ; i++) bb += b[i][1]; cout << bb << ' ' << wb; return 0; }