#include <bits/stdc++.h> using namespace std; using ll = long long; using LL = long long; using i64 = long long; void solve() { ll n; cin >> n; vector <string> t(n); for (int i = 0; i < n; i++)cin >> t[i]; vector <ll> valid(n), valid_1; for (int i = 0; i < n; i++)valid[i] = i; string s; cin >> s; vector <ll> cur(n, 0); bool good = 0; string sol = ""; for (int i = 0; i < s.size(); i++){ for (auto x : valid){ while (cur[x] < t[x].size() && t[x][cur[x]] != s[i]){ sol.push_back(t[x][cur[x]]); cur[x]++; } if (cur[x] < t[x].size())valid_1.push_back(x); } valid = valid_1; valid_1.clear(); if (valid.empty()){ good = 1; break; } sol.push_back(s[i]); if (i+1 == s.size())break; for (auto x : valid){ if (t[x][cur[x]] == s[i])cur[x]++; if (cur[x] < t[x].size())valid_1.push_back(x); } valid = valid_1; valid_1.clear(); } if (good)cout << "YES\n" << sol; else cout << "NO"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; while (t--) solve(); }