The first line contains two integers

)
and

)
, indicating the dimension of the board and the number of additional movements.
The second line contains the name of the given chess piece, which is either ``King'', ``Queen'', ``Rook'', ``Bishop'', or ``Knight''.
The third line contains

positive integers
)
, indicating the size of the board.
The fourth line contains

positive integers
)
, indicating the starting position of the given piece.
The following

lines contains the description of the additional movements.
Each description contains

numbers, where d denotes the number of moved dimensions.
The first number in the description is

)
, and each of the following d pairs of integers
)
in strictly increasing order of

indicates that the

-th coordinate of the chess piece changes by
)
in the move.
It is guaranteed that each movement is valid that the chess piece still stay inside the board after each movement, and the sum of d in all movements is no greater than

.