ha,wa=[*map(int,input().split())] hb,wb=[*map(int,input().split())] hc,wc=[*map(int,input().split())] T=[];t='ABC' H=[ha,hb,hc];W=[wa,wb,wc] for i in range(3): T.append((H[i],W[i],t[i])) T=sorted(T,key=lambda x:(-x[0],x[1])) [print(i[2]) for i in T]