Time limit
2s
Memory limit
128 MB
An 8×8 chessboard contains one king and one stone. A square is written as one letter followed by one number. The letter gives the column, from A on the far left to H on the far right. The number gives the row, from 1 at the bottom to 8 at the top. For example, A1 is the lower-left corner, and B1 is the square immediately to its right.
The king can move in the following ways.
If the king moves onto the square containing the stone, the stone is pushed one square in the same direction as the king's move.

Process the given move commands in order. If a command would move either the king or the stone outside the chessboard, ignore that command and continue with the next one.
Write a program that prints the final positions of the king and the stone.
The first line contains the king's position, the stone's position, and the number of moves N. Each of the next N lines contains one move command for the king. N is a natural number no greater than 50, and every command is one of the eight commands listed above.
Print the king's final position on the first line and the stone's final position on the second line.