brothers = [(chr(ord("A") + i),*map(int,input().split())) for i in range(3)] brothers.sort(key=lambda x:x[2]) brothers.sort(key=lambda x:x[1],reverse=True) for bro in brothers: print(bro[0])