SP120 SOLIT - Solitaire
Description
Solitaire is a game played on an 8x8 chessboard. The rows and columns of the chessboard are numbered from $1$ to $8$, from the top to the bottom and from left to right respectively.
There are four identical pieces on the board. In one move it is allowed to:
- move a piece to an empty neighboring field (up, down, left or right),
- jump over one neighboring piece to an empty field (up, down, left or right).
Input Format
The input begins with the integer t, the number of test cases. Then t test cases follow.
For each test case, each of two input lines contains 8 integers $a_1$ , $a_{2}$ , ..., $a_{8}$ separated by single spaces and describes one configuration of pieces on the chessboard. Integers $a_{2j-1}$ and $a_{2j}$ ($1 \le j \le 4$) describe the position of one piece - the row number and the column number respectively.
Output Format
For each test case the output should contain one word for each test case - `YES` if a configuration described in the second input line is reachable from the configuration described in the first input line in at most $8$ moves, or one word `NO` otherwise.