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 chars[200];
vector<string> strings1;
void check(string cur) {
  for (int j = 0; j < cur.size(); j++) {
    if (chars[cur[j]] != -1) {
      int c = chars[cur[j]];
      for (int k = 0; k < strings1[c].size(); k++) {
        if (strings1[c][k] == cur[j]) {
          int curchars[200];
          int charspos1[200];
          for (int f = 0; f < 200; f++) {
            curchars[f] = 0;
          }
          for (int f = 0; f < cur.size(); f++) {
            curchars[cur[f]] = 1;
            charspos1[cur[f]] = f;
          }
          int charspos2[200];
          for (int f = 0; f < strings1[c].size(); f++) {
            curchars[strings1[c][f]] += 1;
            charspos2[strings1[c][f]] = f;
          }
          string newstr = "";
          int pos1 = j;
          int pos2 = k;
          while (pos1 >= 0 && pos2 >= 0) {
            if (cur[pos1] != strings1[c][pos2]) {
              cout << "NO";
              exit(0);
            }
            if (curchars[cur[pos1]] == 2) {
              if (charspos2[cur[pos1]] != pos2) {
                cout << "NO";
                exit(0);
              }
              curchars[cur[pos1]] = 0;
            }
            newstr = cur[pos1] + newstr;
            pos1--;
            pos2--;
          }
          while (pos1 >= 0) {
            newstr = cur[pos1] + newstr;
            pos1--;
          }
          while (pos2 >= 0) {
            newstr = strings1[c][pos2] + newstr;
            pos2--;
          }
          pos1 = j + 1;
          pos2 = k + 1;
          while (pos1 < cur.size() && pos2 < strings1[c].size()) {
            if (cur[pos1] != strings1[c][pos2]) {
              cout << "NO";
              exit(0);
            }
            if (curchars[cur[pos1]] == 2) {
              if (charspos2[cur[pos1]] != pos2) {
                cout << "NO";
                exit(0);
              }
              curchars[cur[pos1]] = 0;
            }
            newstr = newstr + cur[pos1];
            pos1++;
            pos2++;
          }
          while (pos1 < cur.size()) {
            newstr = newstr + cur[pos1];
            pos1++;
          }
          while (pos2 < strings1[c].size()) {
            newstr = newstr + strings1[c][pos2];
            pos2++;
          }
          for (int f = 0; f < 200; f++) {
            if (curchars[f] == 2) {
              cout << "NO";
              exit(0);
            }
          }
          for (int f = 0; f < strings1[c].size(); f++) {
            chars[strings1[c][f]] = -1;
          }
          strings1[c] = "";
          check(newstr);
          return;
        }
      }
    }
  }
  strings1.push_back(cur);
  for (int j = 0; j < cur.size(); j++) {
    chars[cur[j]] = strings1.size() - 1;
  }
}
int main() {
  int n;
  for (int i = 0; i < 200; i++) {
    chars[i] = -1;
  }
  cin >> n;
  string cur;
  for (int i = 0; i < n; i++) {
    cin >> cur;
    int curchars[200];
    for (int j = 0; j < 200; j++) {
      curchars[j] = 0;
    }
    for (int j = 0; j < cur.size(); j++) {
      if (curchars[cur[j]] == 0) {
        curchars[cur[j]] = 1;
      } else {
        cout << "NO";
        return 0;
      }
    }
    check(cur);
  }
  sort(strings1.begin(), strings1.end());
  for (int i = 0; i < strings1.size(); i++) {
    cout << strings1[i];
  }
  return 0;
}
