CF2171C1.Renako Amaori and XOR Game (easy version)

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Renako Amaori and XOR Game (easy version)

Yup. I couldn't do this any longer. No. Freaking. Way.— Renako Amaori

This is the easy version of the problem. The only difference between the easy and hard versions is that in the easy version, ai,bi1a_i, b_i \leq 1.

Renako is stuck between a rock and a hard place... and by that, of course, I mean Ajisai and Mai! Both of them want to hang out with her, and she just can't decide! So Ajisai and Mai have decided to play the XOR game.

Ajisai and Mai are given arrays aa and bb of length nn (0ai,bi10\leq a_i, b_i\leq {\color{red}{1}}). They will play a game that lasts for nn turns, where Ajisai moves on odd-numbered turns and Mai moves on even-numbered turns. On the ii-th turn, the player to move may choose to swap aia_i and bib_i, or pass.

Note that if a swap occurs, the index that is being swapped must match the turn number. For example, on the first turn, Ajisai may choose to swap a1a_1 and b1b_1, or pass. On the second turn, Mai may choose to swap a2a_2 and b2b_2, or pass. This continues for nn turns. Thus, only Ajisai can swap odd indices, and only Mai can swap even indices.

At the end of the game, Ajisai achieves a score of a1a2ana_1 \oplus a_2 \oplus \dots \oplus a_n, and Mai achieves a score of b1b2bnb_1 \oplus b_2 \oplus \dots \oplus b_n^{\text{∗}}. The player with the higher score wins. If the players have the same score, the game ends in a tie.

Determine the outcome of the game with optimal play. More formally, one player is considered to win with optimal play if there exists a strategy for them such that they always win, regardless of their opponent's choices. The game is considered a tie with optimal play if neither player has such a strategy.

^{\text{∗}}\oplus denotes the bitwise XOR operation

Input

The first line contains a single integer tt (1t1041\leq t\leq 10^4)  — the number of test cases.

The first line of each test case contains a single integer nn (1n21051\leq n\leq 2\cdot 10^5).

The second line of each test case contains nn integers, a1,a2,,ana_1, a_2, \dots, a_n (0ai10\leq a_i\leq 1).

The third line of each test case contains nn integers, b1,b2,,bnb_1, b_2, \dots, b_n (0bi10\leq b_i\leq 1).

It is guaranteed that the sum of nn over all test cases does not exceed 21052\cdot 10^5.

Output

For each test case, output on a single line "Ajisai" if Ajisai wins with optimal play, "Mai" if Mai wins with optimal play, or "Tie" if the game ends in a tie with optimal play.

You may output the answer in any case (upper or lower). For example, the strings "mAi", "mai", "MAI", and "maI" will be recognized as "Mai".

Note

In the first example, one way the game might play out is as follows:

On turn 1, Ajisai chooses to swap a1a_1 and b1b_1. Now the arrays are a=[1,0,0,1]a = [1, 0, 0, 1] and b=[1,0,1,1]b = [1, 0, 1, 1].

On turn 2, Mai chooses to pass.

On turn 3, Ajisai chooses to swap a3a_3 and b3b_3. Now the arrays are a=[1,0,1,1]a = [1, 0, 1, 1] and b=[1,0,0,1]b = [1, 0, 0, 1].

On turn 4, Mai chooses to swap a4a_4 and b4b_4. Now the arrays are a=[1,0,1,1]a = [1, 0, 1, 1] and b=[1,0,0,1]b = [1, 0, 0, 1].

Now, Ajisai's final score is 1011=11\oplus 0\oplus 1\oplus 1 = 1 and Mai's final score is 1001=01\oplus 0\oplus 0\oplus 1 = 0. Therefore, Ajisai wins the game.

It is not guaranteed that the above description is representative of optimal play.

Samples

6
4
1 0 0 1
1 0 1 1
6
0 1 1 1 1 0
0 0 1 0 1 1
4
0 0 1 0
1 0 1 1
5
1 0 1 1 1
0 1 1 1 0
6
1 1 1 1 1 1
1 1 1 1 1 1
5
0 1 0 0 1
1 0 0 1 1
Ajisai
Mai
Tie
Ajisai
Tie
Mai

在线编程 IDE

建议全屏模式获得最佳体验