https://www.luogu.com.cn/problem/P4414
"""
P4414 [COCI2006-2007#2] ABC 02(python3实现)
https://www.luogu.com.cn/problem/P4414
"""
import sys
a=list(map(int,input().split()))
b=list(input())
#print(b)
a.sort()
for i in range(3):
if ord(b[i])-64==1:
print(a[0],end=" ")
if ord(b[i])-64==2:
print(a[1],end=" ")
if ord(b[i])-64==3:
print(a[2],end=" ")