You are given a chessboard, a white piece and a black piece. Each piece can be a king, a queen, a rook, a bishop, or a knight. In how many ways can you place the two pieces so that no piece threatens the other piece? For instance, these are three of the 3612 ways to place two kings on the board:
Input
Input consists of several cases, each one with two chars to indicate the pieces: ‘K’ for a king, ‘Q’ for a queen, ‘R’ for a rook, ‘B’ for a bishop, and ‘N’ for a knight.
Output
For every case, print the number of ways the place the given pieces on the board.
Input
K K R B Q N
Output
3612 2576 2240