
The problem of the relative strength and value of particular groups of figures constantly occurs in the chess game, when there is the question of exchanges. In chess theory the values of figures are measured in pawns. Examples of relationships: Pawn = , Knight = , Bishop = , Rook = , Queen = . You play the "white" and expect your opponent to move. Now only one thing is important for you - what is the most valuable piece of yours that the opponent can capture. It is guaranteed that the answer is always unambiguous.
The first line contains the number of test cases (1 \le t \le 10). Each test case consists of two lines. Its first line contains the number of white figures (1 \le n \le 16), followed by a single space, their positions on the board, as shown in the example. The second line of each test case in the same format describes the black pieces. Marking: K -- King, Q -- Queen, R -- Rook, B -- Bishop, N -- Knight, P -- Pawn. White figures always are placed from the bottom (on the horizontal lines and ). It is guaranteed that the input data is correct and could occur in a real game. We also know that none of the Kings is under attack.
For each test case in a separate line, print the name of the desired figure ("Queen", if it's Queen, "Rook", if the Rook, "Bishop", if the Bishop, "Knight", if the Knight, "Pawn", if the Pawn). If none of your figures is under attack, print "NONE". Print output without quotes!
Example 1