#include #include #include #include using namespace std; string s[20], username, sample; vector ans; void solve (int index) { if (index == sample.size()) { ans.push_back (username); } else { int poz = sample[index] - '0'; for (int i = 0; i < s[poz].size(); i++) { username += s[poz][i]; solve (index + 1); string :: iterator it = username.end(); --it; username.erase (it); } } } int main() { for (int i = 0; i < 10; i++) cin >> s[i]; cin >> sample; solve (0); sort (ans.begin(), ans.end()); for (int i = 0; i < ans.size(); i++) cout << ans[i] << '\n'; return 0; }