a = 'ABC' l = [] for i in 'ABC': h, w = map(int, input().split()) l.append([-h, w , i]) l = sorted(l) for h, w, i in l: print(i)