d={0:'A',1:'B',2:'C'} print(*[d[x[0]] for x in sorted(enumerate(open(0).readlines()),key=lambda x:x[1][:-2],reverse=True)],sep='\n')