really likes chess. In fact, he likes it so much that before going to bed he reads chess problems, and solves them while sleeping. Tonight he can't sleep, so he asks you to help him solve the problem he read.
You are given a chess board with multiple pieces of a single type on it. You can do the following operation several times: take a piece and move it to a square that is occupied by another piece, and remove it. It is important to note that in this problem, pieces don't have to stop when meeting the first piece in their way. In the end you want to have only one piece on the board.
Can you help find a sequence of moves that solves the problem, or say that it is impossible?
How each piece moves:
- The king can make exactly 1 step horizontally, vertically or diagonally
- The queen can make any number of steps horizontally, vertically or diagonally
- The rook can make any number of steps horizontally or vertically
- The bishop can make any number of steps diagonally
- The knight can move in an L-shape: 2 steps horizontally and 1 vertically, or 1 step horizontally and 2 vertically.
Input data
The first line contains an integer () and a character that determines the type of piece on the board (K
- king, Q
- queen, R
- rook, B
- bishop, N
- knight).
The next lines containt characters each, describing the board. The characters can be either .
, meaning an empty square, or , meaning a piece.
Output data
The first line print YES
if the problem can be solved, and NO
otherwise. If the answer was YES
, print the sequence of moves that solves the problem, one move per line. A move is described by integers , meaning that you move a piece from row column to row column .
Example 1
stdin
2 K
K.
KK
stdout
YES
2 2 2 1
2 1 1 1
Example 2
stdin
3 B
B..
B..
..B
stdout
NO
Example 3
stdin
3 Q
.Q.
QQQ
...
stdout
YES
2 3 2 1
2 1 2 2
1 2 2 2