#include <bits/stdc++.h> using namespace std; #define vt vector #define ll long long #define rall(x) (x).rbegin(), (x).rend() #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() const char nl = '\n'; void solve() { int N; cin >> N; vt<int> nxt_pos(N); vt<string> words(N); for(auto& x : words) { cin >> x; } string bad; cin >> bad; string ans; for(int bad_pos = 0; bad_pos < sz(bad); bad_pos++) { for(int i = 0; i < N; i++) { while(nxt_pos[i] < sz(words[i]) && words[i][nxt_pos[i]] != bad[bad_pos]) { ans.push_back(words[i][nxt_pos[i]]); ++nxt_pos[i]; } } bool ok = 1; for(int i = 0; i < N; i++) ok &= nxt_pos[i] >= sz(words[i]); if(ok) break; ans.push_back(bad[bad_pos]); for(int i = 0; i < N; i++) ++nxt_pos[i]; if(bad_pos + 1 == sz(bad)) { cout << "NO" << nl; return; } } cout << "YES" << nl << ans << nl; } int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); }