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.*;
import java.util.*;

public class Solution {


    static MyScanner sc;
    private static PrintWriter out;
    static long M2 = 1_000_000_000L + 7;

    private static HashMap<Long, Long>[] mods;

    public static void main(String[] s) throws Exception {
        StringBuilder stringBuilder = new StringBuilder();
        if (stringBuilder.length() == 0) {
            sc = new MyScanner(System.in);
        } else {
            sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString())));
        }

        out = new PrintWriter(new OutputStreamWriter(System.out));

        initData();
        solve();
        out.flush();
    }

    static boolean[] k = new boolean[101];

    private static void initData() {


    }

    private static void solve() throws IOException {
        int n = sc.nextInt();
        int k = sc.nextInt();

        String[] data = new String[n];
        int[][] md = new int[n][26];
        for (int i = 0; i < n; i++) {
            data[i] = sc.next();
            for (int r = 0; r < k; r++) {
                md[i][data[i].charAt(r) - 'a']++;
            }
        }
        boolean hasDup = Arrays.stream(md[0]).max().getAsInt() > 1;
        int l1 = -1, l2 = -1;
        for (int i = 1; i < n; i++) {
            if (!Arrays.equals(md[i], md[i - 1])) {
                out.println(-1);
                return;
            }
            if (data[i].compareTo(data[i - 1]) != 0) {
                l1 = i;
                l2 = i - 1;
            }
        }
        if (l1 == -1) {
            out.println(new T(data[0], 0, 1));
            return;
        }

        int lr = 0;
        for (int i = 0; i < k; i++) {
            if (data[l1].charAt(i) != data[l2].charAt(i)) {
                lr++;
            }
        }
        if (lr > 4) {
            out.println(-1);
            return;
        }

        int[] m = new int[lr];
        for (int i = 0; i < k; i++) {
            if (data[l1].charAt(i) != data[l2].charAt(i)) {
                m[--lr] = i;
            }
        }


        for (int i = 0; i < m.length - 1; i++) {
            for (int f = i + 1; f < m.length; f++) {
                int x1 = m[i];
                int x2 = m[f];

                T t1 = new T(data[l1], x1, x2);
                T t2 = new T(data[l2], x1, x2);
                if (check(t1, data, hasDup)) {

                    out.println(new StringBuilder(t1).toString());
                    return;
                }
                if (check(t2, data, hasDup)) {

                    out.println(new StringBuilder(t2).toString());
                    return;
                }
            }
        }
        out.println(-1);


    }


    private static boolean check(T t2, String data, boolean hasDup) {
        int d = 0;
        for (int i = 0; i < data.length(); i++) {
            if (data.charAt(i) != t2.charAt(i)) {
                d++;
            }
        }
        return d == 2 || (d == 0 && hasDup);
    }

    private static boolean check(T t2, String[] data, boolean hasDup) {
        for (String p : data) {
            if (!check(t2, p, hasDup)) {
                return false;
            }
        }
        return true;

    }

    private static final class T implements CharSequence {
        String or;
        int f1;
        int f2;

        public T(String or, int f1, int f2) {
            this.or = or;
            this.f1 = f1;
            this.f2 = f2;
        }

        @Override
        public int length() {
            return or.length();
        }

        @Override
        public char charAt(int index) {
            if (index == f1) return or.charAt(f2);
            if (index == f2) return or.charAt(f1);
            return or.charAt(index);
        }

        @Override
        public CharSequence subSequence(int start, int end) {
            return null;
        }

        @Override
        public String toString() {
            StringBuilder l = new StringBuilder();
            for (int i = 0; i < length(); i++) {
                l.append(charAt(i));
            }
            return l.toString();
        }
    }

    private static boolean solve(int n, int p, int p1, int i) {
        return false;
    }


    private static boolean isset(long i, int k) {
        return (i & (1 << k)) > 0;
    }

    private static void solveT() throws IOException {
        int t = sc.nextInt();
        while (t-- > 0) {
            solve();
        }
    }


    private static long gcd(long l, long l1) {
        if (l > l1) return gcd(l1, l);
        if (l == 0) return l1;
        return gcd(l1 % l, l);
    }

    private static long pow(long a, long b, long m) {
        if (b == 0) return 1;
        if (b == 1) return a;
        long pp = pow(a, b / 2, m);
        pp *= pp;
        pp %= m;
        return (pp * (b % 2 == 0 ? 1 : a)) % m;
    }


    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(BufferedReader br) {
            this.br = br;
        }

        public MyScanner(InputStream in) {
            this(new BufferedReader(new InputStreamReader(in)));
        }

        void findToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        String next() {
            findToken();
            return st.nextToken();
        }

        Integer[] nab(int n) {
            Integer[] k = new Integer[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.fi();
            }
            return k;
        }

        int[] na(int n) {
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.fi();
            }
            return k;
        }

        long[] nl(int n) {
            long[] k = new long[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextLong();
            }
            return k;
        }

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

        int fi() {
            String t = next();
            int cur = 0;
            boolean n = t.charAt(0) == '-';
            for (int a = n ? 1 : 0; a < t.length(); a++) {
                cur = cur * 10 + t.charAt(a) - '0';
            }
            return n ? -cur : cur;
        }

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

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


}