#include <bits/stdc++.h> 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() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; void reverse(string& s) { rep(i, 0, sz(s)/2) swap(s[i], s[sz(s)-i-1]); } // struct lis { // lis* nxt, *prev; // string val; // void erase() { // prev->nxt = nxt; // nxt->prev = prev; // } // } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int n; cin >> n; list<string> A(n); for (string& s : A) cin >> s; for (string& s : A) reverse(s); string t; cin >> t; string res = ""; bool broke = false; for (char c : t) { for (auto it = A.begin(); it != A.end();) { while (sz(*it) > 0 && it->back() != c) { res.push_back(it->back()); it->pop_back(); } auto it2 = it; if (sz(*it) == 0) { it = A.erase(it2); } else { it->pop_back(); it++; } } if (sz(A) == 0) { broke = true; break; } res.push_back(c); } if (!broke) { printf("NO\n"); } else { printf("YES\n%s\n", res.c_str()); } }