#include using namespace std; struct bile { int w; int b; }; int main() { int n, m, i, firstBlack = 0, secondWhite = 0; bile b[100000]; cin >> n >> m; for(i = 0; i < n; i++) { cin >> b[i].w >> b[i].b; if(b[i].w > b[i].b) { secondWhite += b[i].w; } else { firstBlack += b[i].b; } } cout << firstBlack << " " << secondWhite; return 0; }