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[26], s;
bool vis[26];
int n, h[26], q[26];
bool cmp(int x, int y) { return A[x] < A[y]; }
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= 25; ++i) h[i] = 0;
  for (int cas = 1; cas <= n; ++cas) {
    cin >> s;
    int len = s.length();
    for (int i = 0; i <= len - 1; ++i) {
      h[s[i] - 'a']++;
      if (h[s[i] - 'a'] > 1) {
        printf("NO\n");
        return 0;
      }
    }
    for (int i = 0; i <= 25; ++i) h[i] = 0;
    for (int i = 0; i <= len - 1; ++i) {
      int c = s[i] - 'a';
      if (A[c].length() == 0) A[c] = A[c] + (char)('a' + c);
      int pos = 0, lenA = A[c].length();
      for (int j = 0; j <= lenA - 1; ++j)
        if (A[c][j] == 'a' + c) pos = j;
      int l = i - 1, r = pos - 1;
      for (; l >= 0 && r >= 0; l--, r--)
        if (s[l] != A[c][r]) {
          printf("NO\n");
          return 0;
        }
      int L = l;
      l = i + 1, r = pos + 1;
      for (; l < len && r < lenA; l++, r++)
        if (s[l] != A[c][r]) {
          printf("NO\n");
          return 0;
        }
      int R = l;
      for (int j = L; j >= 0; --j) A[c] = s[j] + A[c];
      for (int j = R; j <= len - 1; ++j) A[c] = A[c] + s[j];
    }
  }
  for (int i = 0; i <= 25; ++i) vis[i] = true;
  for (int i = 25; i >= 0; --i) {
    for (int j = i + 1; j <= 25; ++j) {
      for (int k = 0; k <= 25; ++k) h[k] = 0;
      int leni = A[i].length(), lenj = A[j].length();
      for (int k = 0; k <= leni - 1; ++k) ++h[A[i][k] - 'a'];
      for (int k = 0; k <= lenj - 1; ++k) ++h[A[j][k] - 'a'];
      int let = -1, posi = 0, posj = 0;
      for (int k = 0; k <= 25; ++k)
        if (h[k] > 1) {
          let = k;
          break;
        }
      if (let < 0) continue;
      for (int k = 0; k <= leni - 1; ++k)
        if (A[i][k] == 'a' + let) posi = k;
      for (int k = 0; k <= lenj - 1; ++k)
        if (A[j][k] == 'a' + let) posj = k;
      int l = posi - 1, r = posj - 1;
      for (; l >= 0 && r >= 0; l--, r--)
        if (A[i][l] != A[j][r]) {
          printf("NO\n");
          return 0;
        }
      int L = r;
      l = posi + 1, r = posj + 1;
      for (; l < leni && r < lenj; ++l, ++r)
        if (A[i][l] != A[j][r]) {
          printf("NO\n");
          return 0;
        }
      int R = r;
      for (int k = L; k >= 0; --k) A[i] = A[j][k] + A[i];
      for (int k = R; k <= lenj - 1; ++k) A[i] = A[i] + A[j][k];
    }
    for (int j = 0; j <= 25; ++j) h[j] = 0;
    for (int j = 0; j <= (int)A[i].length() - 1; ++j) ++h[A[i][j] - 'a'];
    for (int j = 0; j <= 25; ++j)
      if (h[j] > 1) {
        printf("NO\n");
        return 0;
      }
  }
  for (int i = 1; i <= 25; ++i)
    for (int j = 0; j <= i - 1; ++j)
      if (vis[j]) {
        for (int k = 0; k <= 25; ++k) h[k] = 0;
        int leni = A[i].length(), lenj = A[j].length();
        for (int k = 0; k <= leni - 1; ++k) ++h[A[i][k] - 'a'];
        for (int k = 0; k <= lenj - 1; ++k) ++h[A[j][k] - 'a'];
        int let = -1, posi = 0, posj = 0;
        for (int k = 0; k <= 25; ++k)
          if (h[k] > 1) {
            let = k;
            break;
          }
        if (let < 0) continue;
        vis[i] = false;
        break;
      }
  for (int i = 0; i <= 25; ++i) q[i] = i;
  sort(q, q + 26, cmp);
  for (int i = 0; i <= 25; ++i)
    if (vis[q[i]]) cout << A[q[i]];
  cout << endl;
  return 0;
}
