#include using namespace std; int out(int a, int b, vector>&F){ if(F[a - 1][b - 1] != -1) return F[a - 1][b - 1]; cout << a << ' ' << b << endl; string S; cin >> S; if(S == "Black") return 1; else if(S == "White") return 0; else return -1; } struct UnionFind{ vector par; vector rank; UnionFind(int n){ par.resize(n); rank.resize(n); for(int i = 0; i < n; i++){ par[i] = i; rank[i] = 1; } } int root(int x){ if(par[x] == x) return x; else return par[x] = root(par[x]); } bool same(int x, int y){ return root(x) == root(y); } void unite(int x, int y){ x = root(x); y = root(y); if(x == y) return; if(rank[x] < rank[y]) swap(x, y); par[y] = x; rank[x] += rank[y]; } int size(int x) { return rank[root(x)]; } }; int main(){ int N, M; cin >> N >> M; vector> F(N, vector(N, -1)); F[0][0] = 1; F[N - 1][N - 1] = 1; UnionFind U(N * N); queue q; q.push(0); vector> used(N, vector(N, false)); used[0][0] = true; int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; while(!q.empty()){ int now = q.front(); q.pop(); int x = now / N, y = now % N; for(int i = 0; i < 4; i++){ int nx = x + dx[i], ny = y + dy[i]; if(0 <= nx && nx < N && 0 <= ny && ny < N){ int color = out(nx + 1, ny + 1, F); F[nx][ny] = color; if(color == -1){ return 0; } if(color == 1) { U.unite(now, nx * N + ny); if(!used[nx][ny]){ q.push(nx * N + ny); used[nx][ny] = true; } } } } } if(!U.same(0, N * N - 1)) cout << "No" << endl; else cout << "Yes" << endl; }