cup= [True, False, False]

while True:

    try:

        p= list(map(str, input().split(',')))

    except:

        break

    x, y= sorted(p)

    if x=='A' and y=='B':

        cup[0], cup[1]= cup[1], cup[0]

    elif x=='A' and y=='C':

        cup[0], cup[2]= cup[2], cup[0]

    elif x=='B' and y=='C':

        cup[1], cup[2]= cup[2], cup[1]

for i in range(3):

    if cup[i]:

        print(('A' if i==0 else('B' if i==1 else 'C')))

        break
cup = {"A": 1, "B": 0, "C": 0}

while True:

    try:

        x, y = input().split(",")

    except:

        break

    cup[x], cup[y] = cup[y], cup[x]



for k, v in list(cup.items()):

    if v:

        print(k)
cup = [True, False, False]
while True:
    try:
        p = list(map(str, input().split(",")))
    except:
        break
    x, y = sorted(p)
    if x == "A" and y == "B":
        cup[0], cup[1] = cup[1], cup[0]
    elif x == "A" and y == "C":
        cup[0], cup[2] = cup[2], cup[0]
    elif x == "B" and y == "C":
        cup[1], cup[2] = cup[2], cup[1]
for i in range(3):
    if cup[i]:
        print(("A" if i == 0 else ("B" if i == 1 else "C")))
        break

cup = {"A": 1, "B": 0, "C": 0}
while True:
    try:
        x, y = input().split(",")
    except:
        break
    cup[x], cup[y] = cup[y], cup[x]
for k, v in list(cup.items()):
    if v:
        print(k)

-cup = [True, False, False] +cup = {"A": 1, "B": 0, "C": 0} -        p = list(map(str, input().split(","))) +        x, y = input().split(",") -    x, y = sorted(p) -    if x == "A" and y == "B": -        cup[0], cup[1] = cup[1], cup[0] -    elif x == "A" and y == "C": -        cup[0], cup[2] = cup[2], cup[0] -    elif x == "B" and y == "C": -        cup[1], cup[2] = cup[2], cup[1] -for i in range(3): -    if cup[i]: -        print(("A" if i == 0 else ("B" if i == 1 else "C"))) -        break +    cup[x], cup[y] = cup[y], cup[x] +for k, v in list(cup.items()): +    if v: +        print(k)