A = [] for n in ["A", "B", "C"]: h, w = map(int, input().split()) A.append((-h, w, n)) A.sort() for _, _, n in A: print(n)