function Main(input) { let src = input.split("\n"); const a = [...src[0]]; const s = [...src[1]]; let ans = ""; s.forEach(c => { if (isNaN(c)) { ans = ans + c; } else { ans = ans + a[parseInt(c)]; } }); console.log(ans); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));