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;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
const int MAXN = 100000;
vector<int> lst[MAXN];
int parent[MAXN];
void make_set(int v) {
  lst[v] = vector<int>(1, v);
  parent[v] = v;
}
int find_set(int v) { return parent[v]; }
void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (lst[a].size() < lst[b].size()) swap(a, b);
    while (!lst[b].empty()) {
      int v = lst[b].back();
      lst[b].pop_back();
      parent[v] = a;
      lst[a].push_back(v);
    }
  }
}
int main() {
  int n;
  scanf("%d\n", &n);
  std::vector<string> s(n);
  for (int i = 0; i < n; i++) {
    getline(cin, s[i]);
    std::vector<int> cnt(26, 0);
    for (auto x : s[i]) cnt[x - 'a']++;
    for (int j = 0; j < 26; j++)
      if (cnt[j] > 1) {
        printf("NO");
        return 0;
      }
  }
  for (int i = 0; i < n; i++) make_set(i);
  std::vector<std::vector<int> > sym(26);
  for (int i = 0; i < n; i++)
    for (auto x : s[i]) sym[x - 'a'].push_back(i);
  for (int snum = 0; snum < 26; snum++) {
    int k = sym[snum].size();
    for (int i = 0; i < k - 1; i++) {
      int a = find_set(sym[snum][i]);
      int b = find_set(sym[snum][i + 1]);
      if (a != b) {
        int p = s[a].size();
        int q = s[b].size();
        int pos1 = 0, pos2 = 0;
        while (s[a][pos1] != 'a' + snum) pos1++;
        while (s[b][pos2] != 'a' + snum) pos2++;
        int mxp = max(pos1, pos2);
        int len = max(p - pos1, q - pos2) + mxp;
        string news;
        for (int j = 0; j < len; j++) {
          int np1 = j + pos1 - mxp;
          int np2 = j + pos2 - mxp;
          char c1 = '.';
          char c2 = '.';
          if (np1 >= 0 && np1 < p) c1 = s[a][np1];
          if (np2 >= 0 && np2 < q) c2 = s[b][np2];
          if (c1 != '.' && c2 != '.' && c1 != c2) {
            printf("NO");
            return 0;
          } else if (c1 != '.')
            news.push_back(c1);
          else
            news.push_back(c2);
        }
        std::vector<int> cnt(26, 0);
        for (auto x : news) cnt[x - 'a']++;
        for (int j = 0; j < 26; j++)
          if (cnt[j] > 1) {
            printf("NO");
            return 0;
          }
        union_sets(a, b);
        s[find_set(a)] = news;
      }
    }
  }
  std::vector<string> alls;
  for (int i = 0; i < n; i++)
    if (!lst[i].empty()) alls.push_back(s[i]);
  sort((alls).begin(), (alls).end());
  string ans;
  for (auto x : alls) ans = ans + x;
  printf("%s", ans.c_str());
}
