S = 'ABC' l = [list(map(int, input().split())).append(S[i]) for i in range(3)] l.sort(key=lambda x: (x[0], -x[1]), reverse=True) print(list(map(lambda x: x[2], l)))