def checka(a,b,c,d,e,f):
if a!=b and a==c and d!=e and d==f:
return False
else:
return True
def checkb(a,b):
if a==1 and b==0 :
return False
else:
return True
def checkc(a,b,c,d,e,f):
if a==b:
return True
if c==d:
return True
if e==f:
return True
else:
return False
n=int(input())
dic={}
antirule=[]
for i in range(n*2):
dic[i]=list(map(int,input().split()))
i+=1
for m in range(0,n*2,2):
if m<=n:
if checka(dic[m][1],dic[m][3],dic[m][5],dic[m+1][1],dic[m+1][3],dic[m+1][5]):
antirule.append("A")
if checkb(dic[m][6],dic[m+1][6]):
antirule.append("B")
if checkc(dic[m][1],dic[m+1][1],dic[m][3],dic[m+1][3],dic[m][5],dic[m+1][5]):
antirule.append("C")
if len(antirule)==0:
print("None")
else:
print(''.join(antirule))
antirule=[]