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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        static final int UNKNOWN = (int) 1e9;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String[] a = new String[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.next();
            }
            int[][] delta = new int[26][26];
            boolean[] seen = new boolean[26];
            for (int[] x : delta) Arrays.fill(x, UNKNOWN);
            for (int i = 0; i < 26; ++i) delta[i][i] = 0;
            for (String x : a) {
                int first = x.charAt(0) - 'a';
                seen[first] = true;
                for (int i = 1; i < x.length(); ++i) {
                    int second = x.charAt(i) - 'a';
                    seen[second] = true;
                    int got = i;
                    if (delta[first][second] == UNKNOWN) {
                        delta[first][second] = got;
                        delta[second][first] = -got;
                    } else {
                        if (delta[first][second] != got) {
                            out.println("NO");
                            return;
                        }
                    }
                }
            }
            for (int iter = 0; iter < 2; ++iter) {
                for (int k = 0; k < 26; ++k) {
                    for (int i = 0; i < 26; ++i) {
                        for (int j = 0; j < 26; ++j)
                            if (delta[i][k] != UNKNOWN && delta[k][j] != UNKNOWN) {
                                int got = delta[i][k] + delta[k][j];
                                if (delta[i][j] == UNKNOWN) {
                                    delta[i][j] = got;
                                    delta[j][i] = -got;
                                } else {
                                    if (delta[i][j] != got) {
                                        out.println("NO");
                                        return;
                                    }
                                }
                            }
                    }
                }
            }
            for (int i = 0; i < 26; ++i) {
                for (int j = i + 1; j < 26; ++j) {
                    if (delta[i][j] == 0) {
                        out.println("NO");
                        return;
                    }
                }
            }
            char[] res = new char[26];
            int resLen = 0;
            for (int i = 0; i < 26; ++i)
                if (seen[i]) {
                    boolean first = true;
                    for (int j = 0; j < 26; ++j) if (delta[i][j] < 0) first = false;
                    if (first) {
                        int newLen = resLen;
                        for (int j = 0; j < 26; ++j)
                            if (delta[i][j] != UNKNOWN) {
                                res[resLen + delta[i][j]] = (char) ('a' + j);
                                newLen = Math.max(newLen, resLen + delta[i][j] + 1);
                            }
                        resLen = newLen;
                    }
                }
            out.println(new String(Arrays.copyOf(res, resLen)));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

