#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

vector<string> KeyStrings, PossibleStrings;
vector<int> PressedKeys;

void Back(const int index, string &currentString) {
    if (index == int(PressedKeys.size())) {
        PossibleStrings.push_back(currentString);
        return;
    }
    for (int i = 0; i < int(KeyStrings[PressedKeys[index]].size()); ++i) {
        currentString.push_back(KeyStrings[PressedKeys[index]][i]);
        Back(index + 1, currentString);
        currentString.pop_back();
    }
}

void Solve() {
    string currentString = "";
    Back(0, currentString);
    sort(PossibleStrings.begin(), PossibleStrings.end());
    PossibleStrings.erase(unique(PossibleStrings.begin(), PossibleStrings.end()), PossibleStrings.end());
}

void Read() {
    KeyStrings = vector<string>(10, "");
    for (int i = 0; i < 10; ++i)
        cin >> KeyStrings[i];
    string pressedKeys = "";
    cin >> pressedKeys;
    PressedKeys = vector<int>(int(pressedKeys.size()));
    for (int i = 0; i < int(pressedKeys.size()); ++i)
        PressedKeys[i] = int(pressedKeys[i] - '0');
}

void Print() {
    for (int i = 0; i < int(PossibleStrings.size()); ++i)
        cout << PossibleStrings[i] << "\n";
}

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