We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s1, s2, ..., sk. After that, in each of these strings we swapped exactly two characters (the characters we swapped could be identical, but they had different indices in the string).

You are given k strings s1, s2, ..., sk, and you have to restore any string s so that it is possible to obtain these strings by performing aforementioned operations. Note that the total length of the strings you are given doesn't exceed 5000 (that is, k·n ≤ 5000).

Input

The first line contains two integers k and n (1 ≤ k ≤ 2500, 2 ≤ n ≤ 5000, k · n ≤ 5000) — the number of strings we obtained, and the length of each of these strings.

Next k lines contain the strings s1, s2, ..., sk, each consisting of exactly n lowercase Latin letters.

Output

Print any suitable string s, or -1 if such string doesn't exist.

Examples

Input

3 4
abac
caab
acba


Output

acab


Input

3 4
kbbu
kbub
ubkb


Output

kbub


Input

5 4
abcd
dcba
acbd
dbca
zzzz


Output

-1

Note

In the first example s1 is obtained by swapping the second and the fourth character in acab, s2 is obtained by swapping the first and the second character, and to get s3, we swap the third and the fourth character.

In the second example s1 is obtained by swapping the third and the fourth character in kbub, s2 — by swapping the second and the fourth, and s3 — by swapping the first and the third.

In the third example it's impossible to obtain given strings by aforementioned operations.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.TreeMap;

import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Long.parseLong;
import static java.util.Arrays.copyOf;
import static java.util.Arrays.fill;
import static java.util.Arrays.sort;
import static java.util.Collections.reverseOrder;
import static java.util.Collections.sort;

public class Main {
    private FastScanner in;
    private PrintWriter out;

    private void solve() throws IOException {
        solveE();
    }

    private void solveA() throws IOException {

    }

    private void solveB() throws IOException {

    }

    private void solveC() throws IOException {

    }

    private void solveD() throws IOException {

    }

    private HashSet<String> ans;
    private char[][] s;
    private int next, n;
    private boolean dbl;

    private void solveE() throws IOException {
        int k = in.nextInt();
        n = in.nextInt();

        s = new char[k][n];
        for (int i = 0; i < k; i++) {
            s[i] = in.nextLine().toCharArray();
        }

        int alpha = 'z' - 'a' + 1;
        int[] cnt = new int[alpha], cur = new int[alpha];
        for (char c : s[0]) {
            cnt[c - 'a']++;
        }
        for (int i = 1; i < k; i++) {
            fill(cur, 0);
            for (char c : s[i]) {
                cur[c - 'a']++;
            }
            for (int j = 0; j < alpha; j++) {
                if (cnt[j] != cur[j]) {
                    out.print(-1);
                    return;
                }
            }
        }
        for (int i = 0; i < alpha; i++) {
            dbl |= cnt[i] > 1;
        }

        next = 1;
        while (next < k && Arrays.equals(s[0], s[next]))
            next++;

        if (next == k) {
            char cc = s[0][0];
            s[0][0] = s[0][1];
            s[0][1] = cc;
            out.print(new String(s[0]));
            return;
        }

        ans = new HashSet<>();
        find();

        boolean ok;
        for (String ss : ans) {
            ok = true;
            this.cur = ss.toCharArray();
            for (int i = next + 1; i < k && ok; i++) {
                ok = compare(i);
            }
            if (ok) {
                out.print(ss);
                return;
            }
        }

        out.print(-1);
    }

    private HashSet<Integer> unequal;

    private void find() {
        unequal = new HashSet<>();

        for (int i = 0; i < n; i++) {
            if (s[0][i] != s[next][i]) {
                unequal.add(i);
            }
        }

        if ((unequal.size() == 2 && !dbl) || unequal.size() > 4)
            return;

        for (int i = dbl ? 0 : 2; i < 3; i++) {
            possibleAnswers(i);
        }
    }

    private void check(int i) {
        if (s[0][i] == s[next][i])
            unequal.remove(i);
        else
            unequal.add(i);
    }

    private void possibleAnswers(int k) {

        if (k == 0 && unequal.size() != 0)
            return;

        if (unequal.size() == 0) {
            if (k == 0 || dbl)
                ans.add(new String(s[0]));
            return;
        }

        HashSet<Integer> copy = new HashSet<>();
        copy.addAll(unequal);

        for (int i : copy) {
            for (int j : copy) {
                if (s[0][i] == s[next][j]) {
                    if (k == 1) {
                        char c = s[next][j];
                        s[next][j] = s[next][i];
                        s[next][i] = c;
                        check(i);
                        check(j);

                        possibleAnswers(k - 1);

                        c = s[next][j];
                        s[next][j] = s[next][i];
                        s[next][i] = c;
                        check(i);
                        check(j);
                    } else {
                        char c = s[0][j];
                        s[0][j] = s[0][i];
                        s[0][i] = c;
                        check(i);
                        check(j);

                        possibleAnswers(k - 1);

                        c = s[0][j];
                        s[0][j] = s[0][i];
                        s[0][i] = c;
                        check(i);
                        check(j);
                    }
                }
            }
        }

        if (k == 2 && unequal.size() == 2) {
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if ((s[0][i] == s[next][i] ? 1 : 0) + (s[0][j] == s[next][j] ? 1 : 0) == (s[0][i] == s[next][j] ? 1 : 0) + (s[0][j] == s[next][i] ? 1 : 0)) {
                        char c = s[0][j];
                        s[0][j] = s[0][i];
                        s[0][i] = c;
                        check(i);
                        check(j);

                        possibleAnswers(k - 1);

                        c = s[0][j];
                        s[0][j] = s[0][i];
                        s[0][i] = c;
                        check(i);
                        check(j);
                    }
                }
            }
        }
    }

    private char[] cur;

    private boolean compare(int id) {
        unequal = new HashSet<>();

        for (int i = 0; i < n; i++) {
            if (cur[i] != s[id][i]) {
                unequal.add(i);
            }
        }

        if (unequal.size() == 2)
            for (int i : unequal)
                for (int j : unequal)
                    if (i != j && cur[j] == s[id][i] && cur[i] == s[id][j])
                        return true;

        return unequal.size() == 0 && dbl;
    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

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

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }
    }

    private void run() throws IOException {
        in = new FastScanner(System.in); // new FastScanner(new FileInputStream(".in"));
        out = new PrintWriter(System.out); // new PrintWriter(new FileOutputStream(".out"));

        solve();

        out.flush();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}
