#include #include #include using namespace std; #define fi first #define se second #define PII pair #define PIII pair #define Piii(a,b,c) PIII(a,PII(b,c)) int pP, pQ; PIII P[1000], Q[1000]; bool lt(PIII a, PIII b) { if (a.fi+a.se.fi != b.fi+b.se.fi) return a.fi+a.se.fi < b.fi+b.se.fi; return a.fima-mb || (a-b==ma-mb && a>ma)) ma=a, mb=b; } if (pP!=0) { A+=ma; B+=mb; } printf("%d %d\n", A, B); } return 0; }