#include using namespace std; #define st first #define nd second int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; int mn_n = n, mx_n = 1; int mn_m = m, mx_m = 1; for(int i = 0; i < k; i++) { int x, y; cin >> x >> y; mn_n = min(mn_n, x); mx_n = max(mx_n, x); mn_m = min(mn_m, y); mx_m = max(mx_m, y); } vector> stosy; stosy.emplace_back("top", mn_n - 1); stosy.emplace_back("bottom", n - mx_n); stosy.emplace_back("left", mn_m - 1); stosy.emplace_back("right", m - mx_m); int xr = 0; for(auto p : stosy) xr ^= p.nd; auto read = [&]() { string dir; int x; cin >> dir; if(dir == "yuck!") exit(0); cin >> x; for(auto & p : stosy) { if(p.st == dir) { xr ^= p.nd; p.nd -= x; xr ^= p.nd; } } }; auto play = [&]() { for(auto & p : stosy) { int tmp = xr ^ p.nd; if(tmp < p.nd) { cout << p.st << " " << p.nd - tmp << endl; xr = 0; p.nd = tmp; break; } } }; if(xr == 0) cout << "pass" << endl; else play(); while(true) { read(); play(); } }