L = [] for i in 'ABC': L += [list(map(int, input().split())) + [i]] L = sorted(L, key = lambda x : (-x[0], x[1])) for i in range(3): print(L[i][2])