
If room1: {1, 2, 3} and room2: {1, 1}
Then, Axel will be assigned room1 at the beginning of each round, and both Shawn and Axel will pick only one football in each round as they play optimally, this will result in Shawn exhausting the remaining balls in room2 early, and ultimately losing the game.
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows:
The first line of each test case contains two integers ‘N’ and ‘M’ denoting the number of baskets in each of the rooms respectively.
The next two lines of each test case contain the information about the balls in each basket, the first line contains ‘N’ integers denoting the balls in each basket of room-1 and the next line contains ‘M’ integers denoting the balls in each basket present in room-2.
For each test case, print the name of the winner, print “Axel” if it’s possible for Axel to win the game, else print “Shawn”.
Output for each test case will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 ≤ T ≤ 10
1 ≤ N, M ≤ 10000
0 ≤ Room1[i], Room2[i] ≤ 10^9
Time limit: 1 sec
Let’s start from a case when the game is fair and you are not allowed to assign rooms for Axel and Shawn. In this case, each person is assigned a room at the beginning and he continues to play in that room till the end of the game. Both the players will choose one football from any of the non-empty baskets in their room, this will result in Axel winning the game if and only if the total number of footballs in his room is greater than that in Shawn’s room. If both the rooms have an equal number of footballs then Axel will still lose as he is the first one to play his turn in each round.
Now let’s extend this logic to include the fact that you can assign a room to each player at the beginning of each round. From the above discussion about the fair case, the quickest intuition one might get here is that Axel will lose only if both the rooms have an equal number of footballs, but is this condition sufficient? The answer to this is NO, consider a case when room1 = { 1, 2, 3 } and room2 = { 6 }, in this case, both the rooms have an equal number of footballs, but Axel can still win if he is assigned room2 in the first round, as he will pick up all the 6 footballs from the only basket in that room, but Shawn at pickup 3 footballs at max from room1, so the rooms will now become: room1 = { 1, 2, 0 } and room2 = { 0 }, now for the second round Axel can be placed in the room1, and he will surely win as this room has a larger number of footballs. Try to think of the conclusion of this on your own!
To conclude, Axel can only lose the game if and only if the configuration of all non-empty baskets are the same in both the rooms, for all other cases Axel will always win the game.
The steps are as follows :