#include #define For(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rFor(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i) #define rep(i, n) For(i, 0, (n)) #define rrep(i, n) rFor(i, (n), 0) #define fi first #define se second using namespace std; typedef long long lint; typedef unsigned long long ulint; typedef pair pii; typedef pair pll; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template T div_floor(T a, T b) { if (b < 0) a *= -1, b *= -1; return a >= 0 ? a / b : (a + 1) / b - 1; } template T div_ceil(T a, T b) { if (b < 0) a *= -1, b *= -1; return a > 0 ? (a - 1) / b + 1 : a / b; } template struct coord_comp { vector v; bool sorted = false; coord_comp() {} int size() { return v.size(); } void add(T x) { v.push_back(x); } void build() { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); sorted = true; } int get_idx(T x) { assert(sorted); return lower_bound(v.begin(), v.end(), x) - v.begin(); } T &operator[](int i) { return v[i]; } }; constexpr lint mod = 1000000007; constexpr lint INF = mod * mod; constexpr int MAX = 200010; typedef struct UnionFindTree { vector par; UnionFindTree(int n) { par.resize(n, -1); } void clear() { fill(par.begin(), par.end(), -1); } bool is_root(int x) { return par[x] < 0; } int find(int x) { if (is_root(x)) return x; return par[x] = find(par[x]); } int size(int x) { return -par[find(x)]; } bool unite(int x, int y) { x = find(x); y = find(y); if (x == y) return false; if (size(x) < size(y)) swap(x, y); par[x] += par[y]; par[y] = x; return true; } bool same(int x, int y) { return find(x) == find(y); } } UF; int n, m; bool used[510][510]; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int idx(int x, int y) { return x * n + y; } string interact(int x, int y) { cout << x + 1 << " " << y + 1 << endl; string ret; cin >> ret; return ret; } int main() { scanf("%d%d", &n, &m); UF uf(n * n); queue que; que.emplace(0, 0); used[0][0] = true; while (!que.empty()) { auto [x, y] = que.front(); que.pop(); rep(i, 4) { int nx = x + dx[i], ny = y + dy[i]; if (0 <= nx && nx < n && 0 <= ny && ny < n && !used[nx][ny]) { if (interact(nx, ny) == "Black") uf.unite(idx(x, y), idx(nx, ny)); que.emplace(nx, ny); used[nx][ny] = true; } } } cout << (uf.same(idx(0, 0), idx(n - 1, n - 1)) ? "Yes" : "No") << endl; }