| AdaByron Regional Madrid 2024 |
|---|
| Finished |
Chess is a strategic game that involves different phases: opening, middlegame and endgame. Each of the phases requires specific preparation. Many players prioritize the opening: "If I lose in the opening I will never reach an endgame". Others, on the other hand, play openings with very simple plans and their efforts are devoted to studying chess endgame patterns. There are many endgame maneuvers, each with specific concepts, either to win the game or to make a draw.
Some of the most complicated endgames are pawn endgames. It is true that there are not many pieces, but there are too many possible combinations for humans. This problem focuses on the endgame of a pawn and kings (for simplicity, we will assume that the pawn will always be white and there will be no white king).
Given a specific position on a chessboard, your task is to determine if the black king can capture the white pawn. White will try to promote before it is captured (see below for some simplified chess rules).
It is guaranteed that all positions are legal, the white pawn plays optimally and the moves must be legal according to the rules of chess.
There will be several test cases, represented by a number $$$N$$$ given in the first line. For each test case a line is shown containing a positive integer, representing the size of the chessboard ($$$T$$$), and immediately following the character, "B" or "N", indicating the player making the next move ("B", for "Blanco" in Spanish, represents that it is the white pawn's turn, while "N", for "Negro" in Spanish, represents that it is the black king's turn). The next and last line of each case contains four integers separated by spaces: the $$$C_b$$$ column and $$$F_b$$$ row of the white pawn, followed by the $$$C_n$$$ column and $$$F_n$$$ row of the black king.
For each test case, print "SI", if the black king can capture the white pawn, and "NO" otherwise.
2 8 N 1 3 6 2 8 B 1 3 6 2
SI NO
Some chess rules relevant to this problem:
| Name |
|---|


