a = sorted(list(map(int, input().split()))) print(*[a[ord(c) - ord('A')] for c in input()])