h = [list(map(int, input().split())) + list(["A", "B", "C"][i]) for i in range(3)] h.sort(key=lambda x: (-x[0], x[1])) print(*[spec[2] for spec in h], sep="\n")