#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) //#define ATCODER #ifdef ATCODER #include #endif typedef long long ll; typedef unsigned long long ull; #define LINF 9223300000000000000 #define LINF2 1223300000000000000 #define LINF3 1000000000000 #define INF 2140000000 //const long long MOD = 1000000007; const long long MOD = 998244353; using namespace std; #ifdef ATCODER using namespace atcoder; #endif int n, m; int cnt; vector> z; int ask(int i, int j) { if (i < 0 || i >= n || j < 0 || j >= n) { return 1; } if (z[i][j] >= 0) { return z[i][j]; } printf("%d %d\n", i + 1, j + 1); fflush(stdout); char str[10] = { 0 }; scanf("%s", str); if (str[0] == 'B') { z[i][j] = 1; return 1; } else if (str[0] == 'W') { z[i][j] = 0; return 0; } else { return -1; } } int dx[4] = {1,0,-1,0}; int dy[4] = {0,1,0,-1}; void solve() { scanf("%d%d", &n, &m); z.resize(n, vector(n, -1)); z[0][0] = 0; z[n - 1][n-1] = 0; int i = 0, j = 0; int k = 0; // dir while (1) { int knext = -1; for (int p = 3; p <= 6; p++) { int k2 = (k + p) % 4; int i2 = i + dx[k2]; int j2 = j + dy[k2]; int ret = ask(i2, j2); if (ret == -1) { printf("error\n"); return; } else if (ret == 0) { k = k2; i = i2; j = j2; break; } } if (k < 0) { printf("error\n"); return; } if (i == 0 && j == 0) { printf("No\n"); return; } if (i == n - 1 && j == n - 1) { printf("Yes\n"); return; } } return; } int main() { #if 1 solve(); #else int T, t; scanf("%d", &T); for (t = 0; t < T; t++) { //printf("Case #%d: ", t + 1); solve(); } #endif return 0; }