l = [list(map(int, input().split())) + list(["A", "B", "C"][i]) for i in range(3)] sort_l = sorted(l, key = lambda x: (-x[0],x[1])) for i in sort_l: print(i[2])