li=list(map(int, input().split()))
s = input()
li.sort()
d = {'A': li[0], 'B': li[1], 'C': li[2]}
for i in s:
print(d[i], end=' ')