#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector <string> S(N);
    set <int> bad;
    set <int> good;
    vector <int> now(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    string sol = "";
    string unwanted;
    cin >> unwanted;
    int j = 0;
    for (int i = 0; i < N; i++) {
        if (S[i][now[i]] != unwanted[j]) {
            good.insert(i);
        }
        else {
            bad.insert(i);
        }
    }
    while ((bad.size() + good.size() > 0) && j < unwanted.size()) {
        while (good.size()) { // when we have nothing good then we are forced to take bad
            int idx = *good.begin();
            good.erase(good.begin());
            sol += S[idx][now[idx]];
            now[idx]++;
            if (now[idx] < S[idx].size()) {
                if (S[idx][now[idx]] == unwanted[j]) {
                    bad.insert(idx);
                }
                else {
                    good.insert(idx);
                }
            }
        }
        if (bad.size()) { // we are forced to take this
            sol += unwanted[j];
            j++;
            if (j == unwanted.size()) {
                cout << "NO\n";
                return 0;
            }
            set <int> new_bad;
            while (bad.size()) {
                int idx = *bad.begin();
                bad.erase(bad.begin());
                now[idx]++;
                if (now[idx] < S[idx].size()) {
                    if (S[idx][now[idx]] == unwanted[j]) {
                        new_bad.insert(idx);
                    }
                    else {
                        good.insert(idx);
                    }
                }
            }
            for (int x : new_bad)
                bad.insert(x);
        }
    }
    cout << "YES\n";
    cout << sol << "\n";
    return 0;
}