#line 1 "main.cpp"
#include <iostream>
#include <string>

using namespace std;

void solve() {
    string s, t;
    cin >> t >> s;

    for (char &c : s) {
        if (isdigit(c)) c = t[c - '0'];
    }
    cout << s << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}