#include <bits/stdc++.h> using namespace std; using ll = long long; int n; string s, ans; vector<string> v(3e5); vector<int> p(3e5, 0); //vector<vector<int>> cnt(3e5, vector<int>(26, 0)); //vector<set<int>> z(26); vector<int> ki; set <int> undone; bool sft(int i, char c) { while (true) { if (v[i][p[i]] == '#') return false; //cnt[i][c - 'a']--; //if (!cnt[i][c - 'a']) ki.push_back({i, c - 'a'}); if (v[i][p[i]] == c) { p[i]++; return true; } ans.push_back(v[i][p[i]]); p[i]++; } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 0; i < n; i++) { cin >> v[i]; /*for (char c: v[i]) { cnt[i][c - 'a']++; z[c - 'a'].insert(i); }*/ v[i].push_back('#'); undone.insert(i); } cin >> s; for (char c: s) { int k = 0; for (int i: undone){ if (sft(i, c)) k++; else ki.push_back(i); } for (int i : ki) undone.erase(i); ki.clear(); if (!k) { cout << "YES\n" << ans << endl; return 0; } ans.push_back(c); } //cout << ans << "\n"; cout << "NO\n"; }