#include #include #include #include using namespace std; int r[509][509], dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 }; queue > q; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; q.push(make_pair(1, 1)); r[1][1] = 1; while (!q.empty()) { int y = q.front().first, x = q.front().second; q.pop(); for (int i = 0; i < 4; i++) { int tx = x + dx[i], ty = y + dy[i]; if (tx < 1 || tx > n || ty < 1 || ty > n || r[ty][tx]) continue; cout << ty << " " << tx << endl; string s; cin >> s; if (s[0] == 'B') { r[ty][tx] = 1; q.push(make_pair(ty, tx)); } else r[ty][tx] = -1; } } if (r[n][n] == 1) cout << "Yes" << endl; else cout << "No" << endl; return 0; }