#include using namespace std; #define FOR(a, b, c) for(int a = (b); a < (c); a++) #define SZ(a) (int)((a).size()) #define SIZE(a) (int)((a).size()) using ll = long long; #define LL long long #define PB push_back int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int R, C, k; cin >> R >> C >> k; int minx = 1e9, maxx = 0, miny = 1e9, maxy = 0; while(k--) { int x, y; cin >> x >> y; minx = min(minx, x); maxx = max(maxx, x); miny = min(miny, y); maxy = max(maxy, y); } int a = miny - 1; int b = minx - 1; int c = C - maxy; int d = R - maxx; cerr << a << " " << b << " " << c << " " << d << "\n"; string s = "XD"; if((a ^ b ^ c ^ d) == 0) { cout << "pass" << endl; cin >> s; if(s == "yuck!") { return 0; } int x; cin >> x; if(s == "left") { a -= x; } else if(s == "top") { b -= x; } else if(s == "right") { c -= x; } else if(s == "bottom") { d -= x; } } while(s != "yuck!") { int ruch = a ^ b ^ c ^ d; if((a ^ ruch) < a) { cout << "left " << a - (a ^ ruch) << endl; a ^= ruch; } else if((b ^ ruch) < b) { cout << "top " << b - (b ^ ruch) << endl; b ^= ruch; } else if((c ^ ruch) < c) { cout << "right " << c - (c ^ ruch) << endl; c ^= ruch; } else if((d ^ ruch) < d) { cout << "bottom " << d - (d ^ ruch) << endl; d ^= ruch; } cin >> s; if(s == "yuck!") { return 0; } int x; cin >> x; if(s == "left") { a -= x; } else if(s == "top") { b -= x; } else if(s == "right") { c -= x; } else if(s == "bottom") { d -= x; } } }