#include using namespace std; struct iofast_t { iofast_t() { ios::sync_with_stdio(false); cin.tie(nullptr); } } iofast; struct uns_t {} uns; template auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } template > T &chmin(T &l, T r, Compare &&f = less()) { return l = min(l, r, f); } template > T &chmax(T &l, T r, Compare &&f = less()) { return l = max(l, r, f); } optional memo[500][500]; bool query(int y, int x) { if (memo[y][x]) { return *memo[y][x]; } cout << y + 1 << ' ' << x + 1 << endl; string t; cin >> t; if (t == "Black") { return *(memo[y][x] = true); } if (t == "White") { return *(memo[y][x] = false); } exit(1); } int main() { constexpr int step[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 } , { 0, -1 }, }; int n, m; cin >> n >> m; memo[0][0] = true; memo[n - 1][n - 1] = true; if (m < 2 * n - 1) { cout << "No" << endl; return 0; } --m; queue> que; auto vis = vec(false, n, n); que.push({ 0, 0 }); vis[0][0] = true; while (!empty(que) && !vis[n - 1][n - 1] && m != 0) { auto [cy, cx] = que.front(); que.pop(); for (auto [dy, dx] : step) { if (vis[n - 1][n - 1] || m == 0) { break; } int ny = cy + dy; int nx = cx + dx; if (min(ny, nx) < 0 || n <= max(ny, nx)) { continue; } if (vis[ny][nx]) { continue; } if (query(ny, nx)) { vis[ny][nx] = true; que.push({ ny, nx }); --m; } } } cout << (vis[n - 1][n - 1] ? "Yes" : "No") << endl; }