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;
vector<set<int> > adjlist(26);
vector<set<int> > adjrev(26);
int vis[26];
int dfs(int x, vector<int> &v) {
  for (auto it = adjlist[x].begin(); it != adjlist[x].end(); it++) {
    int i = *it;
    if (vis[i] == 2) return 1;
    if (!vis[i]) {
      vis[i] = 2;
      int t = dfs(i, v);
      if (t) return 1;
    }
  }
  v.push_back(x);
  vis[x] = 1;
  return 0;
}
int main() {
  int n, i, j, k;
  cin >> n;
  string arr[n + 1];
  for (int i = 0; i < n; i += 1) {
    cin >> arr[i];
  }
  int vis1[26];
  memset(vis1, 0, sizeof vis1);
  for (int i = 0; i < n; i += 1) {
    int cnt[26];
    memset(cnt, 0, sizeof cnt);
    for (int j = 0; j < arr[i].length(); j += 1) {
      cnt[arr[i][j] - 'a']++;
      vis1[arr[i][j] - 'a'] = 1;
      if (j < arr[i].size() - 1) {
        adjlist[arr[i][j] - 'a'].insert(arr[i][j + 1] - 'a');
        adjrev[arr[i][j + 1] - 'a'].insert(arr[i][j] - 'a');
        if (adjlist[arr[i][j] - 'a'].size() > 1) {
          cout << "NO\n";
          return 0;
        }
        if (adjrev[arr[i][j + 1] - 'a'].size() > 1) {
          cout << "NO\n";
          return 0;
        }
      }
    }
    for (int i = 0; i < 26; i += 1) {
      if (cnt[i] > 1) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  vector<string> v;
  memset(vis, 0, sizeof vis);
  for (i = 0; i < 26; i++) {
    if (vis1[i] && adjrev[i].empty()) {
      vis[i] = 2;
      vector<int> v1;
      int t = dfs(i, v1);
      if (t) {
        cout << "NO\n";
        return 0;
      }
      reverse(v1.begin(), v1.end());
      string s;
      for (int i = 0; i < v1.size(); i += 1) {
        s.push_back((char)(v1[i] + 'a'));
      }
      v.push_back(s);
    }
  }
  for (int i = 0; i < 26; i += 1) {
    if (vis1[i] && !vis[i]) {
      cout << "NO\n";
      return 0;
    }
  }
  sort(v.begin(), v.end());
  string res;
  for (int i = 0; i < v.size(); i += 1) cout << v[i];
  cout << "\n";
}
