A. Pawn vs King Endgame
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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.

Output

For each test case, print "SI", if the black king can capture the white pawn, and "NO" otherwise.

Example
Input
2
8 N
1 3 6 2
8 B
1 3 6 2
Output
SI
NO
Note

Some chess rules relevant to this problem:

  • A piece is captured when the square on which it is located is occupied by an opponent's piece.
  • The king can only move one square in any direction: up, down, sideways or diagonally. In no case can the king move to a square where it would be in check, i.e. where it could be captured.
  • Pawns have the peculiarity that they move and capture in different ways: they move forward, but capture diagonally forward. Pawns can only advance one square in each move, except when they are on rank 2 (initial position in chess games) when they can advance two squares. Pawns can only capture a square located diagonally. They can never move back, not even to capture a piece. Pawns cannot move if on their way they encounter a piece that occupies the square directly in front of them, nor can they capture it. That is, if the pawn is on the square, $$$(F, C)$$$ the only possible moves are:
    1. move to the square $$$(F+1, C)$$$ if the square is empty,
    2. move to the square $$$(F+1, C-1)$$$ or $$$(F+1, C+1)$$$ if the squares are occupied by an opponent's piece,
    3. if $$$F = 2$$$ it can also move to the square $$$(F+2, C)$$$ if the squares $$$(F+1, C)$$$ y $$$(F+2, C)$$$ are empty.
  • A pawn is said to be promoted when it reaches the last row of the board. At this point it can become another piece of your choice (except king or pawn). Note that if it reaches the last row and promotes, the next turn belongs to the opponent, who can immediately capture if it is next to it.