hwa = list(map(int, input().split(' '))) hwb = list(map(int, input().split(' '))) hwc = list(map(int, input().split(' '))) def key(hw): return hw[0] * 1000 + (100 - hw[1]) cand = [ ['A', hwa], ['B', hwb], ['C', hwc]] result = sorted(cand, key=lambda x: key(x[1]), reverse=True) for i in result: print(i[0])