Alice's Lucky Die
Alice and Bob carved their own dice. Alice's die has a faces and Bob's has b faces, and every
face carries an integer. Faces may repeat numbers, so a die may well show 5 on three of its faces.
They each roll their own die once, and whoever shows the higher number wins the round. Equal numbers
are a tie.
Every face of a die is equally likely, so all a·b pairs (Alice's face, Bob's face) are equally
likely. Count how many of these pairs give Alice a win, how many give Bob a win, and how many are
ties. Then say who is favoured: ALICE if Alice wins in more pairs than Bob, BOB if Bob wins in
more pairs than Alice, and FAIR if they win in the same number of pairs.
Two faces showing the same number are still different faces: each counts as its own pair.
Input
The first line contains t (1 ≤ t ≤ 100), the number of test cases.
Each test case consists of three lines:
aandb(1 ≤ a, b ≤ 100), the number of faces on Alice's and Bob's dice;aintegersx_1, …, x_a(1 ≤ x_i ≤ 10^9), the numbers on Alice's faces;bintegersy_1, …, y_b(1 ≤ y_j ≤ 10^9), the numbers on Bob's faces.
Output
For each test case print one line with three integers and a word: the number of pairs where Alice
wins, the number where Bob wins, the number of ties, and then ALICE, BOB or FAIR.
Notes
In the first test case of the first example, Alice's die is 1 4 4 and Bob's is 3 3 5. Alice's
face 1 loses to all three of Bob's faces. Each of her two 4 faces beats both 3 faces and loses
to 5. So Alice wins 2·2 = 4 pairs, Bob wins 3 + 2 = 5 pairs, and there are no ties: Bob is
favoured.
Comparing the totals or averages of the faces does not decide the game. In the second test case of
the first example, Alice's faces add up to 1 + 1 + 1 + 10 = 13, more than Bob's 2 + 2 + 2 + 2 = 8,
yet Bob wins 12 of the 16 pairs.
In the third test case, Alice's 6 beats Bob's 2 and 4 and ties with his 6, while her 2 ties
with his 2 and loses to 6 and 4: two wins each and two ties, so the dice are FAIR.