#include <iomanip>
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include "queue"
//#include <multiset>
#include <map>
#include <utility>
#include <numeric>
#include "random"
#ifndef __clang__
#include <bits/stdc++.h>
#endif
using namespace std;

#define all(x) (x).begin(), (x).end()
#define int long long


void solve() {
    int n, k;
    cin >> n >> k;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        for (auto & j : s[i])
            j -= 'a';
    }
    char c = 't';
    int ans = -1;
    for (int i = 0; i < k; ++i) {
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            bool ok = 1;
            for (auto t : s[j]) {
                if (t != i) {
                    ok = 0;
                    break;
                } else {
                    cnt++;
                }
            }
            if (ok) {
                cnt = -1;
                break;
            }
        }
        if (cnt != -1) {
            cnt++;
            if (ans == -1) {
                ans = cnt;
                c = i + 'a';
            }
            if (ans > cnt) {
                c = i + 'a';
            }
            ans = min(ans, cnt);
        }
    }
    if (ans == -1)
        cout << "NO\n";
    else
        cout << string(ans, c) << '\n';
}

signed main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
