#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(ll i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template bool chmax(T &x, const T &y) {return (x bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;}; constexpr ll MOD=1000000007; constexpr ll INF=2e18; int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; struct Unionfind{ vector par, siz; Unionfind(int N):par(N), siz(N,1){ for (int i=0;i> n >> m; m-=2; Unionfind uf(n*n); queue

q; q.push({0,1}); q.push({1,0}); q.push({n-2,n-1}); q.push({n-1,n-2}); VVI f(n,VI(n,0)); f[0][0]=2; f[n-1][n-1]=2; f[0][1]=1; f[1][0]=1; f[n-2][n-1]=1; f[n-1][n-2]=1; string s; int p=3000; while(!q.empty()&&p>0){ p--; int x=q.front().first, y=q.front().second; q.pop(); cout << x+1 << " " << y+1 << endl; cin >> s; if(s=="White"){ REP(k,4){ int tx=x+dx[k]; int ty=y+dy[k]; if(tx<0||tx>=n||ty<0||ty>=n) continue; if(f[tx][ty]){ if(f[tx][ty]==2) uf.unite(x*n+y,tx*n+ty); continue; } f[tx][ty]=1; q.push({tx,ty}); } f[x][y]=2; m--; } else if(s=="-1") assert(0); if(uf.same(0,n*n-1)){ cout << "Yes" << endl; return 0; } else if(m==0){ cout << "No" << endl; return 0; } } return 0; }