abc = "ABC" hw = [list(map(int, input().split())) + [i] for i in range(3)] hw.sort(key = lambda x:x[1]) hw.sort(reverse = True) for _, _, i in hw: print(abc[i])