#include <fstream>
#include <iostream>
#include <string>
#include <set>

using namespace std;

const int MAXN = 100005;
const int oo = 0x3f3f3f3f;

int N;
set <string> Ans;
string a[20], x;
char st[MAXN];

inline void Back(int K) {
    if(K == N) {
        Ans.insert(string(st));
        return ;
    }
    for(int i = 0 ; i < a[x[K] - '0'].size() ; ++ i) {
        st[K] = a[x[K] - '0'][i];
        Back(K + 1);
    }
}

inline void Solve() {
    for(int i = 0 ; i < 10 ; ++ i)
        cin >> a[i];
    cin >> x;
    N = x.size();
    Back(0);
    for(set <string> :: iterator it = Ans.begin(), fin = Ans.end(); it != fin ; ++ it)
        cout << *it << '\n';
}

int main() {
    Solve();
    return 0;
}