E1. Marisa Kirisame and the Game (Easy Version)
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

This is the easy version of the problem. The difference between the versions is that in this version, the limits on $$$t$$$, $$$n$$$ and $$$m$$$ are smaller. You can hack only if you solved all versions of this problem.

In Gensokyo, Alice Margatroid and Marisa Kirisame are playing a strange game with enchanted pieces. Alice has $$$n$$$ pieces, Marisa has $$$m$$$ pieces, and every piece has an ability value. Both players choose their moves optimally.

Alice moves first, and then the players alternate turns. On a turn, a player may do one of two things:

  1. Skip the turn.
  2. Choose one of her own pieces and one of the opponent's pieces, then compare their ability values. The piece with the smaller value is discarded; if the values are equal, both pieces are discarded.

The game ends immediately after a move if at least one player has no pieces left. If Alice has no pieces and Marisa still has pieces, Marisa wins. If Marisa has no pieces and Alice still has pieces, Alice wins. If both players have no pieces after the same move, the game is a draw. Also, if more than $$$10^{100}$$$ turns have passed without the game ending, the game is a draw.

Input

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). The description of the test cases follows.

The first line of each case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10^4$$$).

The second line of each case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the ability values of Alice's pieces.

The third line of each case contains $$$m$$$ integers $$$b_1, b_2, \ldots, b_m$$$ ($$$1 \le b_i \le 10^9$$$) — the ability values of Marisa's pieces.

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^4$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$10^4$$$.

Output

For each test case, output one line containing A if Alice wins, B if Marisa wins, or C if the game is a draw.

Example
Input
5
2 2
3 1
2 1
2 2
3 1
4 1
2 2
4 1
4 1
3 2
4 3 3
4 4
3 2
4 4 3
4 4
Output
A
B
C
B
C
Note

In the first test case, Alice can use her piece of value $$$3$$$ to defeat all of Marisa's pieces.

In the third test case, the two players have the same pieces, so Marisa can always answer with the symmetric move, and the game is a draw.

In the fifth test case:

  • Alice uses her piece of value $$$4$$$ to defeat one of Marisa's pieces. Now Alice has $$$[4, 3]$$$ and Marisa has $$$[4]$$$.
  • Marisa uses her piece of value $$$4$$$ to defeat Alice's piece of value $$$3$$$. Now Alice has $$$[4]$$$ and Marisa has $$$[4]$$$.
  • From now on, both players only skip their turns.

So $$$10^{100}$$$ turns pass without the game ending, and the game is a draw.