A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.

You are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substrings of this string. Restore the non-empty good string with minimum length. If several such strings exist, restore lexicographically minimum string. If there are no good strings, print "NO" (without quotes).

A substring of a string is a contiguous subsequence of letters in the string. For example, "ab", "c", "abc" are substrings of string "abc", while "ac" is not a substring of that string.

The number of occurrences of a substring in a string is the number of starting positions in the string where the substring occurs. These occurrences could overlap.

String a is lexicographically smaller than string b, if a is a prefix of b, or a has a smaller letter at the first position where a and b differ.

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of strings in the set.

Each of the next n lines contains a non-empty string consisting of lowercase English letters. It is guaranteed that the strings are distinct.

The total length of the strings doesn't exceed 105.

Output

Print the non-empty good string with minimum length. If several good strings exist, print lexicographically minimum among them. Print "NO" (without quotes) if there are no good strings.

Examples

Input

4
mail
ai
lru
cf


Output

cfmailru


Input

3
kek
preceq
cheburek


Output

NO

Note

One can show that in the first sample only two good strings with minimum length exist: "cfmailru" and "mailrucf". The first string is lexicographically minimum.
#include <bits/stdc++.h>
using namespace std;
string a[100005];
bool used[100005];
bool cmp(string a, string b) {
  if (a == "") return false;
  if (b == "") return true;
  return a < b;
}
pair<string, int> sum(string a, int i, string b, int j) {
  int prLen = max(i, j);
  int pxLen = max(a.size() - i - 1, b.size() - j - 1);
  int len = prLen + pxLen + 1;
  string res = "";
  for (int c = 0; c < len; ++c) {
    int posA = i - prLen + c;
    int posB = j - prLen + c;
    if (posA >= 0 && posB >= 0 && posA < a.size() && posB < b.size()) {
      if (a[posA] == b[posB]) {
        res += a[posA];
      } else {
        cout << "NO";
        exit(0);
      }
    } else {
      if (posA >= 0 && posA < a.size()) {
        res += a[posA];
      }
      if (posB >= 0 && posB < b.size()) {
        res += b[posB];
      }
    }
  }
  return {res, prLen};
}
map<char, vector<pair<int, int> > > ch;
string r[255];
int main() {
  int n;
  cin >> n;
  for (int ii = 0; ii < n; ++ii) {
    cin >> a[ii];
  }
  set<char> s;
  for (int ii = 0; ii < n; ++ii) {
    s.clear();
    for (int jj = 0; jj < a[ii].size(); ++jj) {
      if (s.count(a[ii][jj]) > 0) {
        cout << "NO";
        exit(0);
      }
      s.insert(a[ii][jj]);
    }
  }
  for (int ii = 0; ii < n; ++ii) {
    for (int jj = 0; jj < a[ii].size(); ++jj) {
      ch[a[ii][jj]].push_back({ii, jj});
    }
  }
  for (auto it = ch.begin(); it != ch.end(); ++it) {
    if (it->second.size() > 0) {
      int pos = it->second[0].second;
      char cur = a[it->second[0].first][pos];
      r[cur] = a[it->second[0].first];
      for (int i = 1; i < it->second.size(); ++i) {
        if (!used[it->second[i].first]) {
          used[it->second[i].first] = 1;
          auto cc =
              sum(r[cur], pos, a[it->second[i].first], it->second[i].second);
          pos = cc.second;
          r[cur] = cc.first;
        }
      }
    }
  }
  vector<string> res;
  for (int ii = 'a'; ii <= 'z'; ++ii) {
    if (r[ii].size()) res.push_back(r[ii]);
  }
  bool con = true;
  while (con) {
    bool f = false;
    for (int i = 0; i < res.size(); ++i) {
      for (int j = i + 1; j < res.size(); ++j) {
        for (int k = 0; k < res[i].size(); ++k) {
          for (int t = 0; t < res[j].size(); ++t) {
            if (res[i][k] == res[j][t]) {
              f = 1;
              auto cc = sum(res[i], k, res[j], t);
              res[i] = cc.first;
              res[j] = "";
            }
          }
        }
      }
    }
    con &= f;
  }
  sort(res.begin(), res.end(), cmp);
  string res_out = "";
  for (int i = 0; i < res.size(); ++i) {
    res_out += res[i];
  }
  s.clear();
  for (int i = 0; i < res_out.size(); ++i) {
    if (s.count(res_out[i]) > 0) {
      cout << "NO";
      exit(0);
    }
    s.insert(res_out[i]);
  }
  cout << res_out;
}
