3 4
kbub
kbbu
ubkb
 5 5
zbibx
zbbix
zbibx
xbibz
xbibz
 100 2
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
qz
 100 3
zsk
zsk
zsk
zsk
skz
skz
kzs
skz
kzs
kzs
zsk
kzs
kzs
kzs
skz
kzs
skz
skz
kzs
zsk
kzs
kzs
kzs
skz
skz
skz
zsk
skz
zsk
skz
kzs
skz
skz
skz
kzs
zsk
zsk
kzs
skz
skz
kzs
kzs
skz
kzs
kzs
skz
kzs
skz
kzs
kzs
skz
kzs
kzs
kzs
kzs
skz
kzs
skz
skz
skz
skz
zsk
kzs
skz
zsk
kzs
skz
skz
skz
kzs
kzs
skz
skz
kzs
kzs
skz
zsk
skz
zsk
kzs
kzs
skz
kzs
kzs
kzs
zsk
kzs
kzs
zsk
kzs
skz
zsk
skz
skz
skz
kzs
zsk
kzs
kzs
skz
 5 5
eellh
ehlle
ehlle
helle
hlele
 2 3
ghn
ghn
 2 4
ayax
abac
 2 6
abcdef
badcef
 1 2
yu
 2 4
ajax
azad
 2 2
nm
nm
 2 2
ac
ca
 5 5
gyvnn
gnvny
vygnn
gynvn
gnvny
 2 2
ab
cd
 3 3
uvh
vhu
huv
 3 2
xh
xh
xh
 3 2
cg
cg
cg
 8 23
mgiomcytqdvoihhcirldmuj
mgmoicytqdvoihhicrldmuj
mgmomcytqdvoihhicrldiuj
mgcomcytqdvoihhiirldmuj
mgiimcytqdvoihhocrldmuj
mgioicytqdvoihhmcrldmuj
mgiomcytqdvodhhicrlimuj
mgiomcytjdvoihhicrldmuq
 8 6
mnionk
mnikno
inmkno
mnnkio
oniknm
oniknm
mkinno
mnikon
 1 3
vts
 2 3
abc
abz
 2 4
abcd
ccdc
 2 5
dbcag
acbdh
 2 16
hmlqgaepsgpdbzyk
chhhburuvnyirrim

kbub
 zbibx
 zq
 szk
 helle
 hgn
 -1
 bacdef
 uy
 -1
 mn
 -1
 gyvnn
 -1
 vuh
 hx
 gc
 mgiomcytqdvoihhicrldmuj
 mnikno
 tvs
 -1
 -1
 -1
 -1

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 < lr - 1; i++) {
            for (int f = i + 1; f < lr; 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());
        }
    }


}