i = {} i["A"], i["B"], i["C"] = sorted(list(map(int, input().split()))) order = input() print(i[order[0]], i[order[1]], i[order[2]])