import Foundation struct Scanner { private var elements = [String]() private var index = 0 mutating func peek() -> String { while elements.count == index { elements = readLine()!.split(separator: " ").map(String.init) index = 0 } return elements[index] } mutating func next() -> String { defer { index += 1 } return peek() } mutating func nextInt() -> Int { return Int(next())! } mutating func nextInts(_ n: Int) -> [Int] { return (0 ..< n).map { _ in nextInt() } } mutating func nextDouble() -> Double { return Double(next())! } } var scanner = Scanner() let T = [Character](scanner.next()) let S = scanner.next().map { (c) -> Character in if c.isNumber { return T[Int(String(c))!] } else { return c } } print(String(S))