#include <iostream>
using namespace std;
int main()
{
int x[14] = { 0 };
bool a_[30] = { false };
bool b_[30] = { false };
bool c_[30] = { false };
int n = 0;
int i = 0;
int a = 0, b = 0, c = 0;
cin >> n;
while (i < n)
{
for (int i = 0; i < 14; i++)
{
cin >> x[i];
}
if ((x[1] != x[3] && x[8] != x[10]) && (x[1] == x[5] && x[8] == x[12]))
{
a_[i] = true;
}
if (x[6] == 1 && x[13] == 0)
{
b_[i] = true;
}
if (x[1] != x[8] && x[3] != x[10] && x[5] != x[12])
{
c_[i] = true;
}
i++;
}
for (int s = 0; s < n; s++)
{
if (a_[s] == false)
{
cout << "A";
}
if (b_[s] == false)
{
cout << "B";
}
if (c_[s] == false)
{
cout << "C";
}
if (a_[s] == true && b_[s] == true && c_[s] == true)
{
cout << "None";
}
cout << "\n";
}
}