#ifndef LOCAL #pragma GCC optimize("O3") #endif #include using namespace std; #define sim template muu & operator<<( #define ris return *this #define R22(r) sim> typename enable_if<1 r sizeof(dud(0)),muu&>::type operator<<(c g) { sim> struct rge {c b, e;}; sim> rge range(c i, c j) {return rge{i, j};} sim> auto dud(c*r)->decltype(cerr << *r); sim> char dud(...); struct muu { #ifdef LOCAL stringstream a; ~muu() {cerr << a.str() << endl;} R22(<) a << boolalpha << g; ris;} R22(==) ris << range(begin(g), end(g));} sim mor rge u) { a << "["; for (c i = u.b; i != u.e; ++i) *this << ", " + 2 * (i == u.b) << *i; ris << "]"; } sim, class b mor pair r){ris << "(" << r.first << ", " << r.second << ")";} #else sim mor const c&){ris;} #endif }; #define debug muu() << __FUNCTION__ << "#" << __LINE__ << ": " #define imie(r...) "[" #r ": " << (r) << "] " #define range(a, b) "[[" #a ", " #b "): " << range(a, b) << "] " #define arr(a, i) "[" #a imie(i) ": " << a[i] << "] " using ll = long long; using ld = long double; using pii = pair ; char wczyt[107]; int typ['z' + 7]; pair czytaj() { scanf(" %s", wczyt); if (wczyt[0] == 'y') return {4, 0}; int ile; scanf("%d", &ile); return {typ[wczyt[0]], ile}; } int main() { typ['l'] = 2; typ['t'] = 0; typ['b'] = 1; typ['r'] = 3; typ['y'] = 4; int H, W, K; scanf("%d%d%d", &H, &W, &K); int gora = H; int dol = H; int lewo = W; int prawo = W; for (int i = 0; i < K; i++) { int x, y; scanf("%d%d", &y, &x); gora = min(gora, y - 1); dol = min(dol, H - y); lewo = min(lewo, x - 1); prawo = min(prawo, W - x); } int asdf[] = {gora, dol, lewo, prawo}; string co[] = {"top", "bottom", "left", "right"}; auto xoruj = [&asdf]() { int odp = 0; for (int i = 0; i < 4; i++) { odp ^= asdf[i]; } return odp; }; if (xoruj() == 0) { printf("pass\n"); fflush(stdout); } pii wc = {0 ,0}; auto curwa = [&xoruj, &asdf, &co]() { int gg = xoruj(); debug << gg; debug << range(asdf + 0, asdf + 4); for (int i = 0; i < 4; i++) { int a = gg ^ asdf[i]; if (a < asdf[i]) { debug << imie(asdf[i]) imie(a); printf("%s %d\n", co[i].c_str(), asdf[i] - a); asdf[i] = a; fflush(stdout); break; } else { debug << imie(a) imie(asdf[i]) imie(co[i]); } } }; if (xoruj() != 0) curwa(); while ((wc = czytaj()).first != 4) { debug << wc; asdf[wc.first] -= wc.second; curwa(); } }