#include <bits/stdc++.h>
using namespace std;
const int LOG = 32;
vector<int> veca;
vector<int> vecb;
int cnt[LOG];
int last_e[LOG];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t, n, a, b;
cin >> t;
while (t--) {
cin >> n;
veca.clear();
vecb.clear();
for (int i = 0; i < LOG; i++) {
cnt[i] = 0;
last_e[i] = 0;
}
for (int i = 0; i < n; i++) {
cin >> a;
veca.push_back(a);
}
for (int i = 0; i < n; i++) {
cin >> b;
vecb.push_back(b);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < LOG; j++) {
int add = ((veca[i] >> j) & 1) + ((vecb[i] >> j) & 1);
cnt[j] += add;
if (add == 1)
last_e[j] = i + 1;
}
}
bool f = false;
for (int i = LOG - 1; i >= 0; i--) {
if (cnt[i] % 2 == 1) {
f = true;
if (last_e[i] % 2 == 0)
cout << "Mai" << '\n';
else
cout << "Ajisai" << '\n';
break;
}
}
if (!f)
cout << "Tie" << '\n';
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: