table = [] Ha,Wa = input().split() Hb,Wb = input().split() Hc,Wc = input().split() table = [(Ha,Wa,"A"),(Hb,Wb,"B"),(Hc,Wc,"C")] table.sort(key=lambda x:x[1]) table.reverse() table.sort(key=lambda x:x[0]) table.reverse() print(table) for _ in table: print(_[2])