lst = [] for a in "ABC": h,w = map(int,input().split()) lst.append((-h,w,a)) lst.sort() for _,_,a in lst: print(a)