using namespace std; #include <bits/stdc++.h> #define rep(i,b) for(int i = 0; i < b; i++) #define repp(i,a,b) for(int i = a; i < b; i++) typedef long long ll; typedef pair<int,int> p2; #define sz(x) ((int)x.size()) int main() { int n; cin >> n; vector<string> buildme(n); for (auto& v : buildme) cin >> v; string forbid; cin >> forbid; string ans; vector<queue<p2>> q(26); rep(i,n) { q[buildme[i][0]-'a'].emplace(0,i); } int totleft = n; rep(i,sz(forbid)) { int forbidden = forbid[i]-'a'; char forbiddenc = forbid[i]; queue<p2> todo; rep(j,26) { if (j==forbidden) continue; while (sz(q[j])) { todo.push(q[j].front()); q[j].pop(); } } while (sz(todo)) { int prog, ind; tie(prog,ind) = todo.front(); todo.pop(); ans += buildme[ind][prog]; prog++; if (prog!=sz(buildme[ind])) { if (buildme[ind][prog]==forbiddenc) { q[buildme[ind][prog]-'a'].emplace(prog, ind); } else todo.emplace(prog,ind); } else totleft--; } if (totleft==0) break; if (i==sz(forbid)-1) { //cout << ans << "\n"; cout << "NO\n"; return 0; } } cout << "YES\n"; cout << ans << "\n"; return 0; }