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