#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define forn(i,n) for(int i=0; i<n; ++i)

void solve() {
    int n; cin>> n;
    int e; cin>> e;
    vector<string> s(n);
    int maxn = 0;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        s[i] = s[i]+s[i]+s[i];
    }
    string ans = "NO";
    vector<int> cnt(e, 0), ind(n, 0);
    for (int c = 0; c < e; ++c) {
        for (int i = 0; i < 30; ++i) {
            bool added = false;
            for (int j = 0; j < n; ++j) {
                if (ind[j] < s[j].size() && s[j][ind[j]] == 'a'+ c) {
                    cnt[c]++;
                    ind[j]++;
                    added = true;
                }
            }
            if (!added) {
                break;
            }
            if (cnt[c] < i + 1) {
                string cur;
                for (int j = 0; j < i + 1; ++j) {
                    cur.push_back(c + 'a');
                }
                if (cur.size() < ans.size() || ans == "NO") {
                    ans = cur;
                }
            }
        }
    }

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(20);
    int t = 1;
//    cin>>t;
    while (t--) solve();
}
