#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<string> s(n); vector<int> pos(n, 0); vector<vector<int>> v(26); for (int i = 0; i < n; ++i) { cin >> s[i]; v[s[i][0] - 'a'].push_back(i); } string b; cin >> b; int j = 0; string ans; while (1) { bool ok = true; for (int i = 0; i < 26; ++i) { if (!v[i].empty()) { ok = false; break; } } if (ok) { cout << "YES\n" << ans << "\n"; return; } ok = true; for (int i = 0; i < 26; ++i) { if (i != b[j] - 'a' && !v[i].empty()) { auto tmp = v[i]; v[i].clear(); ans.push_back(i + 'a'); for (auto p : tmp) { ++pos[p]; if (pos[p] < s[p].size()) { v[s[p][pos[p]] - 'a'].push_back(p); } } ok = false; } } if (ok) { int i = b[j] - 'a'; ans.push_back(b[j]); ++j; if (j == b.size()) { cout << "NO\n"; return; } auto tmp = v[i]; v[i].clear(); for (auto p : tmp) { ++pos[p]; if (pos[p] < s[p].size()) { v[s[p][pos[p]] - 'a'].push_back(p); } } } } } int main() { cin.tie(NULL); ios::sync_with_stdio(false); int t; t = 1; while (t--) solve(); return 0; }