brothers = [] for name in ["A", "B", "C"]: h, w = map(int, input().split()) brothers.append((h, -w, name)) brothers.sort(reverse=True) for brother in brothers: print(brother[2])