## https://yukicoder.me/problems/no/1588 from collections import deque def main(): N, M = map(int, input().split()) cells = [[-1] * N for _ in range(N)] passed = [[False] * N for _ in range(N)] cells[0][0] = 1 cells[N - 1][N - 1] = 1 passed[0][0] = True m = 2 queue = deque() queue.append((0, 0)) while len(queue) > 0: i, j = queue.popleft() for d_i, d_j in ((-1, 0), (1, 0), (0, 1), (0, -1)): new_i = i + d_i new_j = j + d_j if 0 <= new_i and new_i < N and 0 <= new_j and new_j < N: if passed[new_i][new_j]: continue if cells[new_i][new_j] == 0: continue if cells[new_i][new_j] == 1: passed[new_i][new_j] = True queue.append((new_i, new_j)) continue if M - m > 0: print(f"{new_i + 1} {new_j + 1}") T = input() if T == "White": cells[new_i][new_j] = 0 else: m += 1 cells[new_i][new_j] = 1 passed[new_i][new_j] = True queue.append((new_i, new_j)) else: cells[new_i][new_j] = 0 if passed[N - 1][N - 1]: print("Yes") else: print('No') if __name__ == "__main__": main()