#include using namespace std; /* * */ int main() { int n, m,wb = 0,bb = 0; cin >> n >> m; int **w = new int*[n/2]; int **b = new int*[n/2]; for(int i = 0;i> w[i][0] >> w[i][1]; } for (int i = 0;i < n/2 ; i++) { b[i] = new int[2]; 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; while(1); return 0; }