#c22801. 移棋子游戏

移棋子游戏

Moving the Chess Piece

Problem Description

There is an n×mn \times m board where cell (1,1)(1, 1) is at the top-left and cell (n,m)(n, m) 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 (i,j)(i, j) satisfying 2≤i≤n2 \le i \le n and 2≤j≤m2 \le j \le m, determine which player wins.

Input Format

The first line contains two integers n,mn, m (2≤n,m≤10002 \le n, m \le 1000).

The next line contains m−1m - 1 strings consisting of characters B and W, representing the colors of the first-row cells from column 22 to column mm (B for black, W for white).

The following line contains n−1n - 1 strings consisting of characters B and W, representing the colors of the first-column cells from row 22 to row nn (B for black, W for white).

Output Format

Output n−1n - 1 lines, each containing m−1m - 1 letters indicating the winner. If Alice wins, output A; otherwise output B.

Sample Input

3 4
WBW
BW

Sample Output

AAB
BAA