#pragma GCC optimize("O3") #include <bits/stdc++.h> //#define int long long using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x),end(x) #define sz(x) (int)(x).size() #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n; cin >> n; string t; vector<string> words(n); for(auto &x : words) cin >> x; cin >> t; vector<int> pos(n); vector<vector<int>> has(26); for(int i = 0; i < n; i++) has[words[i][0]-'a'].push_back(i); int post = 0; string sol = ""; for(;;){ int nxt = -1; for(int i = 0; i < 26; i++){ if(!has[i].empty() && (nxt == -1 || nxt == t[post]-'a')) nxt = i; } if(nxt == -1) break; if(nxt == t[post]-'a'){ post++; if(post == sz(t)){ cout << "NO\n"; return 0; } } vector<int> proc = has[nxt]; has[nxt].clear(); for(int i : proc){ pos[i]++; if(pos[i] < sz(words[i])) has[words[i][pos[i]]-'a'].push_back(i); } sol += 'a'+nxt; } cout << "YES\n"; cout << sol << "\n"; }