#include #define maxN 100002 using namespace std; //FILE *fin = freopen("box.in", "r", stdin); /* ------------- */ int n, m; struct Box { int x, y; bool operator < (const Box &a) const { //if (x - y == a.x - a.y) return x > a.x; } } v[maxN]; /* ------------- */ Box ans; void read() { scanf("%d %d", &n, &m); for (int i = 1; i <= n; ++ i) scanf("%d %d", &v[i].x, &v[i].y); } void solve() { sort(v + 1, v + n + 1); for (int i = 1; i <= n; ++ i) if (i <= n / 2) ans.x += v[i].x; else ans.y += v[i].y; } void write() { printf("%d %d\n", ans.y, ans.x); } int main() { read(); solve(); write(); return 0; }