a = int(input())
for j in range(a):
Z=[]
b =list(map(int,input().split()))
if b[1] == b[3] or b[1] != b[5]:
Z.append("A")
c =list(map(int,input().split()))
if c[1] == c[3] or c[1] != c[5]:
if Z==[]:
Z.append("A")
if b[-1]!=1 or c[-1]!=0:
Z.append("B")
for i in range(1,7,2):
if b[i]==c[i]:
Z.append("C")
break
if Z==[]:
print("None")
else:
for i in range(len(Z)-1):
print(Z[i],end="")
print(Z[len(Z)-1])