#include <iostream> #include <algorithm> using namespace std; struct config{ int wi,bi;}x[100001]; int N,M; 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[i]=y; } sort(x,x+N,comp); int tWi=0,tBi=0; for(int i=0;i<N;i++) { if(i<N/2) tWi += x[i].wi; else tBi+= x[i].bi;} cout << tBi << " " << tWi; return 0; }