import sys
for line in sys.stdin:
if line != "\n":
rightlist = [int(temp) for temp in line.split()]
n = int(input())
for i in range(n):
templist = []
for temp in rightlist:
templist.append(temp)
trylist = [int(trytemp) for trytemp in input().split()]
p = 0
q = 0
plist = []
minuslist = []
for j in range(len(trylist)):
if templist[j] == trylist[j]:
p = p + 1
plist.append(j)
minuslist.append(templist[j])
#print(plist)
for k in minuslist:
templist.remove(k)
trylist.remove(k)
#print(templist,trylist)
for l in range(len(templist)):
for m in range(len(trylist)):
if templist[l] == trylist[m]:
q = q + 1
print(str(p)+'A'+str(q)+'B')
else:
break
import sys
rightlist = [int(temp) for temp in input().split()]
n = int(input())
for i in range(n):
templist = []
for temp in rightlist:
templist.append(temp)
trylist = [int(trytemp) for trytemp in input().split()]
p = 0
q = 0
plist = []
minuslist = []
for j in range(len(trylist)):
if templist[j] == trylist[j]:
p = p + 1
plist.append(j)
minuslist.append(templist[j])
#print(plist)
for k in minuslist:
templist.remove(k)
trylist.remove(k)
#print(templist,trylist)
for l in range(len(templist)):
for m in range(len(trylist)):
if templist[l] == trylist[m]:
q = q + 1
print(str(p)+'A'+str(q)+'B')
m = input()
rightlist = [int(temp) for temp in input().split()]
n = int(input())
for i in range(n):
templist = []
for temp in rightlist:
templist.append(temp)
trylist = [int(trytemp) for trytemp in input().split()]
p = 0
q = 0
plist = []
minuslist = []
for j in range(len(trylist)):
if templist[j] == trylist[j]:
p = p + 1
plist.append(j)
minuslist.append(templist[j])
#print(plist)
for k in minuslist:
templist.remove(k)
trylist.remove(k)
#print(templist,trylist)
for l in range(len(templist)):
for m in range(len(trylist)):
if templist[l] == trylist[m]:
q = q + 1
print(str(p)+'A'+str(q)+'B')