#include #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; int n, m; int query(int i, int j) { cout << i + 1 << ' ' << j + 1 << endl; string ret; cin >> ret; if (ret == "-1") exit(0); return ret == "Black"; } int state[500][500]; bool added[500][500]; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; int main() { ios::sync_with_stdio(false); cin.tie(0); rep(i, 500) rep(j, 500) state[i][j] = -1; state[0][0] = 1; cin >> n >> m; auto mycmp = [&](pair& x, pair& y) { return x.first > y.first; }; priority_queue, vector>, decltype(mycmp)> q(mycmp); q.emplace(n - 1 + n - 1 - 1, P{0, 1}); q.emplace(n - 1 + n - 1 - 1, P{1, 0}); added[0][0] = added[0][1] = added[1][0] = true; rep(_, 3000) { if (q.empty()) break; auto [d, p] = q.top(); q.pop(); if (d == 0) { cout << "Yes\n"; return 0; } auto [i, j] = p; state[i][j] = query(i, j); if (state[i][j]) { rep(k, 4) { int ni = i + dx[k], nj = j + dy[k]; if (!(0 <= ni && ni < n && 0 <= nj && nj < n)) continue; if (added[ni][nj]) continue; added[ni][nj] = true; q.emplace(n - 1 - ni + n - 1 - nj, P{ni, nj}); } } } cout << "No\n"; }