#![allow(unused_imports)] #![allow(non_snake_case, unused)] fn read() -> Vec { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().split_whitespace().map(|s| String::from(s)).collect() } use std::cmp::*; use std::collections::*; use std::ops::*; use std::marker::*; const INF: i64 = std::i64::MAX/100; const MOD: i64 = 1_000_000_007; // const MOD: i64 = 998_244_353; fn main() { let (n, m): (usize, usize) = { let a = read(); (a[0].parse().unwrap(), a[1].parse().unwrap()) }; let mut seen = vec![vec![false;n];n]; let mut ans = false; dfs(0,0,4,&mut seen,&mut ans); if ans { println!("Yes"); } else { println!("No"); } } fn dfs(x: usize, y: usize, d: usize, mut seen: &mut Vec>, mut ans: &mut bool){ let n = seen.len(); if x==n-1 && y==n-1 { *ans = true; return; } println!("{} {}",x+1,y+1); let t = read(); if t[0]=="White" { return; } seen[x][y] = true; let dir = [(0,1),(1,0),(0,!0),(!0,0)]; for (nd,&(tx,ty)) in dir.iter().enumerate() { if d<4 && d!=nd && nd%2==d%2 { continue; } let nx = x + tx; let ny = y + ty; if nx>=n || ny>=n { continue; } if seen[nx][ny] { continue; } seen[nx][ny] = true; dfs(nx,ny,nd,&mut seen,&mut ans); } }