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 int inf = 1e9;
const double eps = 1e-9;
const int INF = inf;
const double EPS = eps;
struct __timestamper {};
int main() {
  int k;
  while (scanf("%d", &k) == 1) {
    vector<string> ss(k);
    for (auto &s : ss) {
      static char buf[int(1e5) + 100];
      scanf("%s", buf);
      s = buf;
    };
    const int n = 26;
    vector<int> pr(n, -1), ne(n, -1);
    vector<bool> was(n, true);
    for (const auto &s : ss) {
      for (int i = 0; i + 1 < ((int)(s).size()); i++) {
        int x = s[i] - 'a', y = s[i + 1] - 'a';
        assert(0 <= x && x < n);
        assert(0 <= y && y < n);
        ;
        if (ne[x] >= 0 && ne[x] != y) {
          printf("NO\n");
          goto end;
        }
        ne[x] = y;
        if (pr[y] >= 0 && pr[y] != x) {
          printf("NO\n");
          goto end;
        }
        pr[y] = x;
      }
      for (char c : s) {
        was[c - 'a'] = false;
      }
    };
    {
      vector<string> ans;
      for (int st = 0; st < ((int)(was).size()); st++)
        if (!was[st]) {
          ;
          string cur = "";
          for (int i = st; i >= 0; i = ne[i]) {
            ;
            if (was[i]) {
              printf("NO\n");
              goto end;
            }
            was[i] = true;
            cur += 'a' + i;
          }
          string cur2 = "";
          for (int i = pr[st]; i >= 0; i = pr[i]) {
            ;
            if (was[i]) {
              printf("NO\n");
              goto end;
            }
            was[i] = true;
            cur2 += 'a' + i;
          }
          reverse(cur2.begin(), cur2.end());
          ;
          ans.push_back(cur2 + cur);
        }
      sort(ans.begin(), ans.end());
      string res = "";
      for (const string &s : ans) res += s;
      printf("%s\n", res.c_str());
    }
  end:;
  }
  return 0;
}
