a=['A','B','C'];h=[input() for _ in '1'*3] ah=sorted(dict(zip(a,h)).items(), key=lambda x: x[1], reverse=True) for i in ah: print(i[0])