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;
char a[100010][31], s[100010];
int pos[100010][31], f[100010], len[100010], n, A[100010];
inline int find(int x) {
  if (x == f[x]) return x;
  return f[x] = find(f[x]);
}
inline int merge(int x, int y, int ch) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return 1;
  f[fy] = fx;
  int pos1 = pos[fx][ch], pos2 = pos[fy][ch];
  if (pos1 < pos2) {
    for (int i = 1; i <= len[fy]; i++) s[i] = a[fy][i];
    for (int i = pos2 - pos1 + 1, j = 1; i <= pos2 - pos1 + len[fx]; i++, j++) {
      if (i <= len[fy]) {
        if (s[i] != a[fx][j]) return 0;
      } else
        s[i] = a[fx][j];
    }
    len[fx] = max(len[fy], pos2 - pos1 + len[fx]);
    if (len[fx] > 26) return 0;
    memset(pos[fx], 0, sizeof(pos[fx]));
    for (int i = 1; i <= len[fx]; i++) {
      a[fx][i] = s[i];
      if (pos[fx][a[fx][i] - 'a'] == 0)
        pos[fx][a[fx][i] - 'a'] = i;
      else
        return 0;
    }
  } else {
    for (int i = 1; i <= len[fx]; i++) s[i] = a[fx][i];
    for (int i = pos1 - pos2 + 1, j = 1; i <= pos1 - pos2 + len[fy]; i++, j++) {
      if (i <= len[fx]) {
        if (s[i] != a[fy][j]) return 0;
      } else
        s[i] = a[fy][j];
    }
    len[fx] = max(len[fy] + pos1 - pos2, len[fx]);
    if (len[fx] > 26) return 0;
    memset(pos[fx], 0, sizeof(pos[fx]));
    for (int i = 1; i <= len[fx]; i++) {
      a[fx][i] = s[i];
      if (pos[fx][a[fx][i] - 'a'] == 0)
        pos[fx][a[fx][i] - 'a'] = i;
      else
        return 0;
    }
  }
  return 1;
}
inline bool cmp(const int &x, const int &y) { return a[x][1] < a[y][1]; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    int m = strlen(s + 1);
    len[i] = m;
    if (m > 26) {
      cout << "NO" << endl;
      return 0;
    }
    for (int j = 1; j <= m; j++) {
      a[i][j] = s[j];
      if (pos[i][a[i][j] - 'a'] == 0)
        pos[i][a[i][j] - 'a'] = j;
      else {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int ch = 0; ch < 26; ch++) {
    int last = 0;
    for (int i = 1; i <= n; i++)
      if (pos[i][ch] != 0) {
        if (last != 0) {
          if (merge(last, i, ch) == 0) {
            cout << "NO" << endl;
            return 0;
          }
        }
        last = i;
      }
  }
  int tot = 0;
  for (int i = 1; i <= n; i++)
    if (find(i) == i) A[++tot] = i;
  sort(A + 1, A + tot + 1, cmp);
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= len[A[i]]; j++) cout << a[A[i]][j];
  return 0;
}
