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;
int n, m, x, y, z, k, w;
char t[123456];
string s[100005];
int l[123], LINK[123456], ed[123456], cost[123456], deg[123], vis[123];
int freq[29], v[100005], A[30];
char ans[12345];
long long val1, val2, m1 = 1000000007ll, m2 = 1000000009ll;
set<pair<long long, long long>> M;
void bd(int x, int y, int z) {
  LINK[w] = l[x];
  l[x] = w;
  cost[w] = z;
  ed[w++] = y;
  deg[y]++;
}
int check(int x, int y) {
  int a = A[x], b = A[y];
  int len = min(s[a].length(), s[b].length());
  string ta, tb;
  int res = 0;
  for (int i = (0); i < (len); i++) {
    ta = "";
    tb = "";
    for (int j = (s[a].length() - i - 1); j < (s[a].length()); j++)
      ta += s[a][j];
    for (int j = (0); j < (i + 1); j++) tb += s[b][j];
    if (ta == tb) res = i + 1;
  }
  return res;
}
void trace(int x, int overlap) {
  vis[x] = 1;
  int a = A[x];
  for (int i = (overlap); i < (s[a].length()); i++) ans[w++] = s[a][i];
  if (l[x] != -1) trace(ed[l[x]], cost[l[x]]);
}
int tar, cnt, val;
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    scanf("%s", t);
    m = strlen(t);
    for (int j = (0); j < (26); j++) freq[j] = 0;
    for (int j = (0); j < (m); j++) freq[t[j] - 'a']++;
    for (int j = (0); j < (m); j++)
      if (freq[t[j]] > 1) {
        printf("NO\n");
        return 0;
      }
    for (int j = (0); j < (m); j++) s[i] = s[i] + t[j];
  }
  sort(s, s + n);
  for (int i = (0); i < (n); i++) {
    m = s[i].length();
    for (int j = (0); j < (m); j++) {
      val1 = val2 = 0ll;
      for (int k = (j); k < (m); k++) {
        val1 *= 117ll;
        val1 += s[i][k];
        val1 %= m1;
        val2 *= 129ll;
        val2 += s[i][k];
        val2 %= m2;
        if (j == 0 && k == m - 1) continue;
        if (M.find(make_pair(val1, val2)) == M.end())
          M.insert(make_pair(val1, val2));
      }
    }
  }
  for (int i = (0); i < (n); i++) {
    m = s[i].length();
    val1 = val2 = 0ll;
    for (int k = (0); k < (m); k++) {
      val1 *= 117ll;
      val1 += s[i][k];
      val1 %= m1;
      val2 *= 129ll;
      val2 += s[i][k];
      val2 %= m2;
    }
    if (M.find(make_pair(val1, val2)) == M.end()) v[i] = 1;
  }
  k = 0;
  for (int i = (0); i < (n); i++)
    if (v[i] == 1) A[k++] = i;
  if (k > 26) {
    printf("NO\n");
    return 0;
  }
  w = 0;
  memset(l, -1, sizeof(l));
  for (int i = (0); i < (k); i++) {
    val = 0;
    for (int j = (0); j < (k); j++) {
      if (i == j) continue;
      y = check(i, j);
      if (y > val)
        val = y, tar = j, cnt = 1;
      else if (y == val)
        cnt++;
    }
    if (val == 0) continue;
    if (cnt > 1) {
      printf("NO\n");
      return 0;
    }
    bd(i, tar, val);
  }
  for (int i = (0); i < (k); i++)
    if (deg[i] > 1) {
      printf("NO\n");
      return 0;
    }
  w = 0;
  for (int i = (0); i < (k); i++)
    if (deg[i] == 0) trace(i, 0);
  for (int i = (0); i < (k); i++)
    if (vis[i] == 0) {
      printf("NO\n");
      return 0;
    }
  for (int i = (0); i < (26); i++) freq[i] = 0;
  for (int i = (0); i < (w); i++) freq[ans[i] - 'a']++;
  for (int i = (0); i < (26); i++)
    if (freq[i] > 1) {
      printf("NO\n");
      return 0;
    }
  printf("%s\n", ans);
  return 0;
}
