use std::collections::VecDeque; const INF: usize = 1usize << 60; const DX: [isize; 4] = [-1, 1, 0, 0]; const DY: [isize; 4] = [0, 0, -1, 1]; fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; let mut grid = vec![vec![INF; m]; n]; let mut deque = VecDeque::new(); deque.push_back((0usize, 0usize)); while let Some((x, y)) = deque.pop_front() { if grid[x][y] < INF { continue; } println!("{} {}", x + 1, y + 1); let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim(); if s == "Black" { grid[x][y] = 1; for dir in 0..4 { let nx = x as isize + DX[dir]; let ny = y as isize + DY[dir]; if nx >= 0 && ny >= 0 && nx < n as isize && ny < m as isize { let nx = nx as usize; let ny = ny as usize; if grid[nx][ny] < INF { continue; } deque.push_back((nx, ny)); } } } else { grid[x][y] = 0; } } if grid[n-1][m-1] == INF { println!("No"); } else { println!("Yes"); } }