#include using namespace std; int main() { string a, s; cin >> a >> s; for (char c: s) { if (isdigit(c)) { printf("%c", a[c-'0']); } else { printf("%c", c); } } puts(""); return 0; }