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

public class e {


    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        int n = in.nextInt();
        int k = in.nextInt();
        
        char[][] strs = new char[n][];
        for (int i = 0; i < n; i++) {
            strs[i] = in.next().toCharArray();
        }
        
        IntList[] indices = new IntList[n];
        boolean[] hasRepeat = new boolean[n];
        int max = 0;
        for (int i = 1; i < n; i++) {
            boolean[] has = new boolean[26];
            indices[i] = new IntList();
            for (int j = 0; j < k; j++) {
                if (strs[0][j] != strs[i][j]) {
                    indices[i].add(j);
                }
                if (has[strs[i][j] - 'a']) {
                    hasRepeat[i] = true;
                }
                has[strs[i][j] - 'a'] = true;
            }
            max = Math.max(max, indices[i].size());
        }
        
        if (max > 4) {
            out.println(-1);
            out.close();
            return;
        }
        
        for (int ai = 0; ai < k; ai++) {
            for (int bi = ai + 1; bi < k; bi++) {
                char t = strs[0][ai];
                strs[0][ai] = strs[0][bi];
                strs[0][bi] = t;
                
                boolean good = true;
                
                for (int i = 1; i < n; i++) {
                    IntList inds = indices[i];
                    if (inds.size() == 0) continue;
                    inds.add(ai);
                    inds.add(bi);
                    
                    if (hasRepeat[i] && check(strs[0], strs[i], inds)) {
                        inds.n--;
                        inds.n--;
                        continue;
                    }
                    boolean good2 = false;
outer: 
                    for (int cii = 0; cii < inds.size(); cii++) {
                        for (int dii = cii; dii < inds.size(); dii++) {
                            int ci = inds.get(cii);
                            int di = inds.get(dii);
                            if (ci == di) continue;
                            t = strs[i][ci];
                            strs[i][ci] = strs[i][di];
                            strs[i][di] = t;
                            
                            boolean tmp = check(strs[0], strs[i], inds);
                            
                            t = strs[i][ci];
                            strs[i][ci] = strs[i][di];
                            strs[i][di] = t;
                            
                            if (tmp) {
                                good2 = true;
                                break outer;
                            }
                        }
                    }
                    
                    inds.n--;
                    inds.n--;
                    if (!good2) {
                        good = false;
                        break;
                    }
                }
                
                if (good) {
                    out.println(new String(strs[0]));
                    out.close();
                    return;
                } else {
                    t = strs[0][ai];
                    strs[0][ai] = strs[0][bi];
                    strs[0][bi] = t;
                }
            }
        }
        
        
        out.println(-1);
        
        out.close();
    }


    static boolean check(char[] a, char[] b, IntList inds) {
        for (int i = 0; i < inds.size(); i++) {
            int j = inds.get(i);
            if (a[j] != b[j]) return false;
        }
        return true;
    }
    static Random rand = new Random();
    static void sort(int[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static void sort(long[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            long tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static void sort(double[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            double tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    static long[] eEuclid(long a, long b) {
        if (b == 0) return new long[] { a, 1, 0 };
        long[] ans = eEuclid(b, a % b);
        long temp = ans[1] - ans[2] * (a / b);
        ans[1] = ans[2];  ans[2] = temp;
        return ans;
    }
    static long modInverse(long a, long m) {
        return ((eEuclid(a, m)[1] % m) + m) % m;
    }
    static class IntList {
        static int[] EMPTY = {};
        int[] a = EMPTY;
        int n = 0;
        void add(int v) {
            if (n >= a.length)
                a = Arrays.copyOf(a, (n << 2) + 8);
            a[n++] = v;
        }
        int get(int idx) {
            return a[idx];
        }
        int size() {
            return n;
        }
    }
    static class DisjointSet {
        int[] s, r;	
	public DisjointSet(int n) {
            s = new int[n]; r = new int[n];
            for (int i = 0; i < n; i++) s[i] = i;
        }	
        public int find(int i) { return s[i] == i ? i : (s[i] = find(s[i])); }
	public void union(int a, int b) {
            if(r[a = find(a)] == r[b = find(b)]) r[a]++;
            if(r[a] >= r[b]) s[b] = a; else s[a] = b;
        }
    }
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if(st.hasMoreTokens())
                return st.nextToken();
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public int[] nextOffsetIntArray(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt() - 1;
            return arr;
        }
        public int[] nextIntArray(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt();
            return arr;
        }
        public int[][] nextIntArray(int n, int m) throws IOException {
            int[][] arr = new int[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextInt();
            return arr;
        }
        public long[] nextLongArray(int n) throws IOException {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextLong();
            return arr;
        }
        public long[][] nextLongArray(int n, int m) throws IOException {
            long[][] arr = new long[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextLong();
            return arr;
        }
        public double[] nextDoubleArray(int n) throws IOException {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextDouble();
            return arr;
        }
        public double[][] nextDoubleArray(int n, int m) throws IOException {
            double[][] arr = new double[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextDouble();
            return arr;
        }
        public char[][] nextCharArray(int n, int m) throws IOException {
            char[][] arr = new char[n][];
            for (int i = 0; i < n; i++)
                arr[i] = next().toCharArray();
            return arr;
        }
    }
}
