#include <iostream> #include <algorithm> #include <vector> using namespace std; struct config { int wi,bi; }; int N,M; vector < pair <int,int> > x; bool comp(config x, config y) { if (x.wi >y.wi) return true; return false; } int main() { cin >> N >>M; for(int i=0; i<N; i++) { config y; cin >> y.wi >> y.bi; x.push_back(make_pair(y.wi,y.bi)); } sort(x.begin(),x.end()); int tW=0,tB=0; for(int i=0; i<N/2; i++) { tW += x[i].second; } for(int i=N/2; i<N; i++) { tB += x[i].first; } cout << tW << " " << tB; return 0; }