s = input() m = input().strip() print("".join([s[int(m[i * 3 : i * 3 + 3]) - 1] for i in range(len(m) // 3)]))