You are given an infinite chessboard. In this task, a chessboard is an infinite two-dimensional grid of squares, where each square is indexed by a pair of integers (r, c), denoting the row and the column respectively. The only piece currently present on the chessboard is the superpiece. You are given a list of valid moves of your superpiece, which will be specified as a non-empty string containing a subset of the characters in "QRBNKP". In each turn, the superpiece can move as one of the given chess pieces. The superpiece is initially positioned at square (a, b). Calculate the minimum number of moves needed to reach the square (c, d).
The subset of the chess rules applicable for this problem are given below.
There are six types of pieces: queen, rook, bishop, knight, king and pawn. They move the following way:






Note that the other rules or moves that you might know about chess do not apply in this problem; please only use the ones listed above.
Also, note that while the symbol denoting the chess piece is often the first letter of its name in English, it is the second letter for the "kNight" (to avoid confusion with the "King").
The first line of the input contains an integer q, representing the number of queries your program will be tested on. Each two of the following lines describe a query:
For each of the q queries, output a single line containing an integer m representing the minimum number of moves the superpiece needs to reach the target from its original position for that query. If it is not possible to reach the target from the original position for a query, output −1 instead.