#include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; const string Black = "Black"; const string White = "White"; int dh[4] = {0, 0, -1, 1}; int dw[4] = {-1, 1, 0, 0}; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, m; cin >> n >> m; vector> asked(n, vector(n)); vector> ok(n, vector(n)); auto ask = [&](int a, int b){ if(a < 0 || a >= n || b < 0 || b >= n) return false; if(asked[a][b]) return ok[a][b] == true; cout << a+1 << ' ' << b+1 << endl; string t; cin >> t; ok[a][b] = t==Black; asked[a][b] = true; return ok[a][b] == true; }; asked[0][0] = true; ok[0][0] = true; asked[n-1][n-1] = true; ok[n-1][n-1] = true; vector> visited(n, vector(n)); function dfs = [&](int i, int j){ visited[i][j] = true; if(i == n-1 && j == n-1) return true; for(int k = 0; k < 4; k++){ int i_to = i+dh[k]; int j_to = j+dw[k]; if(ask(i_to, j_to)){ if(!visited[i_to][j_to]) { if(dfs(i_to, j_to)) return true; } } } return false; }; if(dfs(0, 0)) cout << "Yes" << endl; else cout << "No" << endl; }