프로그램 명: boi_gam
제한시간: 1 초

Two players, A and B, play a game on a square board of size n × n. The squares of the board are either white or black. The game is played only on the white squares fi the black ones are excluded from the game. Each player has one piece, initially placed at this player’s starting point fi one of the white squares on the board. The starting point of A is difierent than that of B. In each move a player moves his piece to one of the neighboring white squares (either up, down, left or right). If the player moves his piece to the square currently occupied by his opponent’s piece, he gets an extra move (this way he jumps over the opponent). Note that in this case the direction of the second move can be difierent than that of the first move.

Player A moves first, then players alternate. The goal of the game is to reach the opponent’s starting point. The player whose piece reaches his opponent’s starting point first, wins the game. Even if the player’s last move consists of two jumps, and he only jumps over his opponent’s starting point (since it is occupied by his opponent), the player wins. We want to determine which player has a winning strategy (a player has a winning strategy if he can win regardless of his opponent’s moves).

Figure 1. If A moves to the right on his first three moves, B will move up the first three moves. Thus, on the third move player B will reach the square with A’s piece and will be allowed to move again. Because of this, B will reach A’s starting point first and will win the game.

Figure 2. A can start by moving one step to the right and one step down. Then, depending on the first two moves of B, he will either go down or right and evade B. This way A will reach B’s starting point first, thus winning the game. In fact we proved that A has a winning strategy.

Task

Write a program, that:

입력

You may assume that there exists a path of white squares between the starting points of A and B.

Additionally, in test cases worth 60% of points, n <= 150 and in test cases worth 40% of points, n <= 40 .

출력

For each test case exactly one line should be printed to standard output containing a single character ’A’ or ’B’, indicating the player who has a winning strategy.

입출력 예

입력

2
4
A...
.#..
....
...B
4
A...
....
..#.
...B

출력

B
A
출처:BOI 2008  2/7

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]