Problem D: Dicey Dice

Players A and B play a game with a set of 3 dice as follows:

First, one of the two players picks one die. Then the other player picks one of the remaining two dice. Finally, both roll their die. If both roll the same number, the game is a tie, otherwise the player with the highest roll wins. The game is fair if both players have the exact same winning probability, but that may not be so since not all dice are created equally...

Input Format

First line of the input contains an integer G, the number of games (1 ≤ G ≤ 200). Then follows 4*G lines, where each 4 consecutive lines contains the description of one game. The first of the 4 lines contains either the character 'A' or the character 'B', which is the name of the player who goes first to choose a die in that game. Each of the next 3 lines contains 6 numbers, the numbers on the six sides of each of the 3 dice used in that game. Each number is an integer between 1 and 100.

Output Format

For each game, print one line with the text "fair", "A", or "B" (without quotes), where "A" or "B" indicates the name of the player having an advantage in that particular game. Both players play optimally, always picking the die that is most beneficial for themselves.

Sample Input

3
A
1 1 1 1 1 1
2 3 2 4 5 3
6 6 6 6 6 6
A
4 3 7 9 2 5
8 1 4 6 9 2
6 5 1 8 3 7
B
1 2 3 4 4 4
1 2 3 4 4 4 
1 2 3 4 4 4

Sample Output

A
B
fair

Peter Høyer
ACPC 2013