B. Sacrifice The Rook
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are a GothamChess subscriber. Playing a game of chess, you are nearing the end. It is your turn; you have a king and a rook, and your opponent has a king.

As every GothamChess subscriber knows, in this position, you need to sacrifice THE ROOOOOOOK!!!!!!!!

To sacrifice the rook, you must make a move such that the opponent's king can legally capture the rook on the next move. (Thus accepting the sacrifice)

Can you sacrifice the rook in one move?

Rules of Chess:

A chessboard is an $$$8$$$ by $$$8$$$ grid of squares. The columns are files, labeled $$$a$$$ – $$$h$$$. The rows are ranks, labeled $$$1$$$ – $$$8$$$. Kings and rooks are referred to as pieces, and they each occupy a square on the board. The location of a piece can be specified by the file, then the rank.

Each piece is controlled by one of the players. Specifically, in our problem, you control a king and a rook, and the opponent controls a king. On a player's turn, they select one of their pieces and move it.

A king can move one square horizontally, vertically, or diagonally. If it lands on an opponent's piece, it can capture it, but it may not land on an allied piece. Also, it may not move into check. (That is, it cannot move into a square where it could be captured on the opponent's turn.)

A rook can move any number of squares horizontally or vertically, but cannot move through other pieces. If it lands on an opponent's piece, it can capture it. It may not land on an allied piece.

Additional Constraints:

It is guaranteed that the positions are valid. The opponent's king is not under attack. That is, you will not be able to capture your opponent's king on your turn.

Castling is not possible in this position (understanding castling is unnecessary for solving this problem).

Input

Each test contains multiple test cases. The first line of the input is $$$T (1 \leq T \leq 10^4)$$$, the number of test cases.

$$$T$$$ lines follow, containing a test case. Each test case contains the location of your king, your rook, and your opponent's king, in that order.

Tests in subtasks are numbered from $$$1−20$$$ with samples skipped. Each test is worth $$$\frac{100}{20}=5$$$ points.

Tests $$$1-20$$$ satisfy no additional constraints.

Output

For each test case, output 'YES' if you can sacrifice the rook in one move, or 'NO' if you can't, on separate lines. The checker is case sensitive, so make sure to capitalize your output!

Example
Input
6
c5 e2 f4
c3 d5 h4
f2 g2 h1
b4 d6 f3
d2 e6 f1
d4 b4 f4
Output
YES
YES
YES
NO
NO
NO
Note

These pieces are your king, your rook, and your opponent's king, from left to right.

In the first test case, you can move your rook to e4. Your opponent's king is legally able to capture your rook.

In the second test case, you can move your rook to g5. Your opponent's king is legally able to capture your rook.

In the third test case, you can move your king to f3. Your opponent's king is legally able to capture your rook.

In the fourth test case, you are unable to move your rook to a position that can be captured by the opponent's king.

In the fifth test case, you can move your rook to e2, but your opponent can't capture it because if they do, then your king would be able to capture their king on the next turn, and kings are not allowed to make moves that would allow them to get captured. Similar logic with moving your rook to e1.

In the sixth test case, your king blocks your rook. Thus, you are unable to move your rook to a position that can be captured by the opponent's king.

Problem Idea: Alex_C

Problem Preparation: nyctivoe + Alex_C

Occurrences: Novice B