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 First line of the input contains an integer G, the number of games (1 ≤ G ≤ 825). 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 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 111111 232453 666666 A 437925 814692 651837 B 123444 123444 123444 Sample Output A B fair