#c22801. 移棋子游戏
移棋子游戏
Moving the Chess Piece
Problem Description
There is an board where cell is at the top-left and cell is at the bottom-right. Each cell in the first row and the first column is colored either black or white.
A chess piece is placed on the board. Alice and Bob take turns moving the piece, with Alice moving first. In each move, the piece may be moved one cell up or one cell left. Once the piece reaches the first row or the first column, the game ends. The player who makes the last move wins if the piece ends up on a black cell, and loses otherwise.
For every starting position satisfying and , determine which player wins.
Input Format
The first line contains two integers ().
The next line contains strings consisting of characters B and W, representing the colors of the first-row cells from column to column (B for black, W for white).
The following line contains strings consisting of characters B and W, representing the colors of the first-column cells from row to row (B for black, W for white).
Output Format
Output lines, each containing letters indicating the winner. If Alice wins, output A; otherwise output B.
Sample Input
3 4
WBW
BW
Sample Output
AAB
BAA