HA_dict = dict() H, W = map(int, input().split()) HA_dict["A"] = (H, W) H, W = map(int, input().split()) HA_dict["B"] = (H, W) H, W = map(int, input().split()) HA_dict["C"] = (H, W) HA_dict = sorted(HA_dict.items(), key=lambda x:x[1][1]) HA_dict = sorted(HA_dict, reverse=True, key=lambda x:x[1][0]) for i in range(3): print(HA_dict[i][0])