l = [] for i in 'ABC': h, w = map(int, input().split()) l.append([i, h, w]) l = sorted(l, key=lambda x: (-x[1], x[2])) for i in l: print(i[0])