a,b,c=sorted(map(int,input().split())) m=input() dic={'A':a,'B':b,'C':c} for i in m: print("%d"%dic[i],end=' ')