#include using namespace std; using ll = long long; int a[502][502]; int main() { int n, m; cin >> n >> m; for (int i = 0; i <= n + 1; i++) { for (int j = 0; j <= n + 1; j++) { a[i][j] = -1; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { a[i][j] = 0; } } a[1][1] = 1; a[n][n] = 1; m -= 2; queue> q; q.push({ 1, 1 }); int l = 0; while (!q.empty() && m > 0) { auto p = q.back(); q.pop(); pair d[4] = { { 0, 1 }, { 1, 0 }, { -1, 0 }, { 0, -1 } }; for (int k = 0; k < 4; k++) { auto t = p; t.first += d[k].first; t.second += d[k].second; int &x = a[t.first][t.second]; if (x != 0) continue; if (l == 3000) break; cout << t.first << ' ' << t.second << endl; l++; string s; cin >> s; if (s[0] == '-') { exit(0); } x = s[0] == 'B' ? 1 : 2; if (x == 1) { if ((t.first == n - 1 && t.second == n) || (t.first == n && t.second == n - 1)) { cout << "Yes" << endl; exit(0); } q.push(t); m--; } } } cout << "No" << endl; return 0; }