HW = map(int, open(0).read().split()) A = sorted(zip("ABC", HW, HW), key=lambda x: x[2]) A.sort(key=lambda x: -x[1]) for s, _, _ in A: print(s)