P = {} for c in ['A', 'B', 'C']: H, W = map(int, input().split()) P[c] = [H, W] P = sorted(sorted(P.items(), key=lambda x:x[1][1]), key=lambda x:-x[1][0]) for K in P: print(K[0])