#K85257. Game Winner Determination
Game Winner Determination
Game Winner Determination
In this problem, two players, Ananya and Amar, play a turn‐based game. The game starts with a score of 0. In each move, a player can add any allowed number from a given set (S) to the current score. The goal is to reach exactly the target score (T). Both players play optimally. It is known that if the current score is (i), and there exists an allowed move (m \in S) such that the resulting state (i+m) is a losing position for the opponent, then the position (i) is a winning position. Using this idea, determine the winner. If the starting position (0) is winning, then Ananya wins; otherwise, Amar wins.
inputFormat
The input is read from standard input. The first line contains a single integer (T) which denotes the number of test cases. Each test case consists of two lines: the first line contains the target score (T) (an integer), and the second line contains a sequence of space-separated integers representing the allowed moves (each element of set (S)).
outputFormat
For each test case, output a single line to standard output containing the winner's name. Output "Ananya" if the first player has a winning strategy, otherwise output "Amar". Each result should be printed on a new line.## sample
2
10
2 3 5
15
4 7 9
Ananya
Amar
</p>