#include <bits/stdc++.h>
using namespace std;

constexpr int INF = 1e9 + 41;

string solve(int n, int E, const vector<string>& keys) {
  map<char, int> b0;
  map<char, int> b1;
  for (const auto& s : keys) {
    size_t i = 1;
    while (i < s.length() && s[i] == s[0]) {
      i++;
    }
    if (i == s.length()) {
      b0[s[0]] = INF;
    } else {
      b0[s[0]] += static_cast<int>(i);
    }
    b1[s[0]] += 1;
  }
  int mn = int(1e9);
  for (char ch = 'a'; ch < static_cast<char>('a' + E); ch++) {
    if (b0[ch] < INF) {
      mn = min(mn, b1[ch]);
    }
  }
  char bst = '#';
  size_t ans = INF;
  for (char ch = 'a'; ch < static_cast<char>('a' + E); ch++) {
    if (b1[ch] != mn) {
      continue;
    }
    int cur = b0[ch];

    if (cur < ans) {
      ans = cur;
      bst = ch;
    }
  }
  return ans >= INF ? "NO" : string(ans + 1, bst);
}

int main() {
#ifdef LOCAL
  std::ignore = freopen("../a.in", "r", stdin);
#endif
  int n, E;
  vector<string> keys;
  cin >> n >> E;
  keys.resize(n);
  for (auto &s: keys) cin >> s;

  cout << solve(n, E, keys) << "\n";
}
