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;
using ll = long long;
using uint = unsigned int;
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
template <class T, class U>
void chmax(T& x, U y) {
  if (x < y) x = y;
}
template <class T, class U>
void chmin(T& x, U y) {
  if (y < x) x = y;
}
template <class T>
void mkuni(V<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "{";
  for (const T& v : vc) o << v << ",";
  o << "}";
  return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
struct unionfind {
  int par[100001];
  long long d[100001];
  void init(int n) {
    for (int i = 0; i < int(n); i++) par[i] = i, d[i] = 0;
  }
  int find(int x) {
    if (x == par[x]) return x;
    int r = find(par[x]);
    d[x] += d[par[x]];
    return par[x] = r;
  }
  bool unite(int x, int y, int z) {
    int rx = find(x), ry = find(y);
    if (rx == ry) {
      if (diff(x, y) != z) return false;
      return true;
    }
    d[ry] = d[x] - d[y] - z;
    par[ry] = rx;
    return true;
  }
  int diff(int x, int y) {
    find(x), find(y);
    return d[x] - d[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
} UF;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int N;
  cin >> N;
  V<string> t(N);
  for (int i = 0; i < int(N); i++) cin >> t[i];
  for (int i = 0; i < int(N); i++) {
    set<char> st;
    for (char c : t[i]) st.insert(c);
    if (int(st.size()) != int(t[i].size())) {
      cout << "NO" << endl;
      return 0;
    }
  }
  UF.init(N);
  using P = pair<int, int>;
  map<char, V<P>> c2ps;
  for (int i = 0; i < int(N); i++) {
    for (int j = 0; j < int(int(t[i].size())); j++) {
      c2ps[t[i][j]].emplace_back(P(i, j));
    }
  }
  for (auto it : c2ps) {
    auto v = it.second;
    for (auto q : v) {
      auto p = v[0];
      if (!UF.unite(p.first, q.first, p.second - q.second)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < int(N); i++) UF.find(i);
  VV<int> r2vs(N);
  for (int i = 0; i < int(N); i++) r2vs[UF.find(i)].emplace_back(i);
  V<string> ans;
  for (int r = 0; r < int(N); r++)
    if (r2vs[r].size()) {
      map<int, char> mp;
      for (int i : r2vs[r]) {
        for (int j = 0; j < int(int(t[i].size())); j++) {
          int idx = -UF.d[i] + j;
          if (mp.count(idx)) {
            if (mp[idx] != t[i][j]) {
              cout << "NO" << endl;
              return 0;
            }
          }
          mp[idx] = t[i][j];
        }
      }
      string tmp;
      for (auto it : mp) tmp += it.second;
      ans.emplace_back(tmp);
    }
  void(0);
  sort(ans.begin(), ans.end());
  for (string s : ans) cout << s;
  cout << endl;
}
