dic = {}

dic.setdefault('a',str(eval(input()))+'E')

dic.setdefault('b',str(eval(input()))+'E')

dic.setdefault('c',str(eval(input()))+'E')

dare = dic['a'][0]

dic['a'] = dic['a'][1:]

while len(dic['a'])>0 and len(dic['b'])>0 and len(dic['c'])>0:

    tmp = dic[dare][0]

    dic[dare] = dic[dare][1:]

    if tmp=='E':

        ans = dare.upper()

    dare = tmp

print(ans)

dic = {}

dic.setdefault('a',str(eval(input()))+'A')

dic.setdefault('b',str(eval(input()))+'B')

dic.setdefault('c',str(eval(input()))+'C')

dare = dic['a'][0]

dic['a'] = dic['a'][1:]

while len(dic['a'])>0 and len(dic['b'])>0 and len(dic['c'])>0:

    tmp = dic[dare][0]

    dic[dare] = dic[dare][1:]

    dare = tmp

print(dare)

dic = {}
dic.setdefault("a", str(eval(input())) + "E")
dic.setdefault("b", str(eval(input())) + "E")
dic.setdefault("c", str(eval(input())) + "E")
dare = dic["a"][0]
dic["a"] = dic["a"][1:]
while len(dic["a"]) > 0 and len(dic["b"]) > 0 and len(dic["c"]) > 0:
    tmp = dic[dare][0]
    dic[dare] = dic[dare][1:]
    if tmp == "E":
        ans = dare.upper()
    dare = tmp
print(ans)

dic = {}
dic.setdefault("a", str(eval(input())) + "A")
dic.setdefault("b", str(eval(input())) + "B")
dic.setdefault("c", str(eval(input())) + "C")
dare = dic["a"][0]
dic["a"] = dic["a"][1:]
while len(dic["a"]) > 0 and len(dic["b"]) > 0 and len(dic["c"]) > 0:
    tmp = dic[dare][0]
    dic[dare] = dic[dare][1:]
    dare = tmp
print(dare)

-dic.setdefault("a", str(eval(input())) + "E") -dic.setdefault("b", str(eval(input())) + "E") -dic.setdefault("c", str(eval(input())) + "E") +dic.setdefault("a", str(eval(input())) + "A") +dic.setdefault("b", str(eval(input())) + "B") +dic.setdefault("c", str(eval(input())) + "C") -    if tmp == "E": -        ans = dare.upper() -print(ans) +print(dare)