ls = [] n = ['A','B','C'] for i in range(3): h,w = map(int,input().split()) ls.append((h,w,n[i])) ls.sort(key=lambda x:x[1]) ls.sort(key=lambda x:-x[0]) for i in range(3): print(ls[i][2])