Hide

Problem O
Check

You are given a position on a chessboard. Determine whether or not the white king is currently in check. All pieces capture as they normally do in chess. Those rules can be found here.

\includegraphics[scale=0.5]{chessboard.png}

Input

The first line of the input contains a single integer $t$ ($1 \le t \le 10^4$) —the number of test cases. The description of the test cases follows.

Each test case consists of $8$ lines of $8$ characters each, representing the pieces on the chessboard. $K$, $Q$, $R$, $B$, $N$, and $P$ represent the white king, queen(s), rook(s), bishop(s), knight(s), and pawn(s), respectively. $q$, $r$, $b$, $n$, and $p$ represent the black queen(s), rook(s), bishop(s), knight(s), and pawn(s), respectively. There will be no black king in the input. $.$ represents an empty space. The top left square of the input is $a8$ and the bottom right square is $h1$.

There is one empty line in between testcases.

It is guaranteed that there is exactly one white king and no black king on the board, and no pawns are on the first or last row. Note that since there is no black king, this position is not reachable in actual game of chess, and there are no additional restrictions on the input.

Output

For each test case, output “Yes” (without quotes) if the white king is currently in check, and “No” otherwise. You can output the answer in any case (upper or lower). For example, the strings “Yes”, “yes”, “Yes”, and “YES” will be recognized as positive responses.

Sample Input 1 Sample Output 1
7
rnbq.bnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR

........
.....p..
..P..K..
........
....Q...
........
.B......
b....r..

........
.....p..
..P..K..
........
....Qn..
........
.B......
b....r..

b......q
........
...n....
........
....NP..
......P.
......rR
K.......

b......q
........
...n....
........
...QNP..
.n....P.
......rR
K.......

........
...p....
....K...
........
........
........
........
........

........
........
....K...
...p....
........
........
........
........
No
Yes
No
Yes
Yes
Yes
No

Please log in to submit a solution to this problem

Log in