#include using namespace std; #define ll long long const int MAXN = 505; int dx[4] = {0, 0, -1, 1}; int dy[4] = {1, -1, 0, 0}; int vis[MAXN][MAXN]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int cnt = 0; int found = 1; bool possible = 0; queue> q; q.emplace(1,1); while (cnt < 2999 && !q.empty() && found < m) { auto cur = q.front(); int cx = cur.first; int cy = cur.second; q.pop(); if (vis[cx][cy] != 0) continue; cout << cx << " " << cy << endl; string s; cin >> s; if (s[0] == 'B') { vis[cx][cy] = 1; found++; if ((cx == n && cy == n) || (cx == n-1 && cy == n) || (cx == n && cy == n-1)) { possible=1; break; } } else if (s[0] == 'W') { vis[cx][cy] = 2; continue; } else { cout << "ERR" << endl; return 0; } cnt++; for (int d = 0; d < 4; ++d) { int nx = cx + dx[d]; int ny = cy + dy[d]; if (nx <= n && nx >= 1 && ny <= n && ny >= 1 && vis[nx][ny] == 0) { q.emplace(nx, ny); } } } if (possible) { cout << "Yes" << endl; } else { cout << "No\n"; } return 0; }