s = 'ABC' n = sorted([int(i) for i in input().split()]) m = [s.index(i) for i in input()] print('{} {} {}'.format(n[m[0]],n[m[1]],n[m[2]]))