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


// Problem : E. Swapping Characters
// Contest : Codeforces - Educational Codeforces Round 34 (Rated for Div. 2)
// URL : https://codeforces.com/contest/903/problem/E
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class a implements Runnable{
	
    public static void main(String[] args) {
        new Thread(null, new a(), "process", 1<<26).start();
    }
	public void run() {
		FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		//PrintWriter out = new PrintWriter("file.out");
		Task solver = new Task();
		//int t = scan.nextInt();
		int t = 1;
		for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
		out.close();
	}

	static class Task {
		static final int inf = Integer.MAX_VALUE;

		public void solve(int testNumber, FastReader sc, PrintWriter pw) {
			//CHECK FOR QUICKSORT TLE
			//***********************//
			//CHECK FOR INT OVERFLOW
			//***********************//
			int k = sc.nextInt();
			int n = sc.nextInt();
			HashMap<Long, Integer> keep = new HashMap<>();
			HashMap<Long, Integer> combo = new HashMap<>();
			long[] pow31 = new long[n + 1];
			pow31[0] = 1;
			for(int i = 1; i <= n; i++) {
				pow31[i] = pow31[i - 1] * 31;
				pow31[i] %= 1000000007;
			}
			long[] pow61 = new long[n + 1];
			pow61[0] = 1;
			for(int i = 1; i <= n; i++) {
				pow61[i] = pow61[i - 1] * 61;
				pow61[i] %= 1000000007;
			}
			int mod = 1000000007;
			String first = "";
			for(int s = 0; s < k; s++) {
				String str = sc.nextLine();
				if(s == 0) first = str;
				CharHash hash31 = new CharHash(str.toCharArray(), 31);
				CharHash hash61 = new CharHash(str.toCharArray(), 61);
				long cd = 1l * hash31.hash(0, n) * mod + hash61.hash(0, n);
				HashSet<Long> hs = new HashSet<Long>();
				for(int i = 0; i < n; i++) {
					int[] alr = new int[26];
					for(int j = i + 1; j < n; j++) {
						if(alr[str.charAt(j) - 'a'] == 0) {
							alr[str.charAt(j)- 'a']++;
							long h31 = hash31.hash(j + 1, n);
							long h61 = hash61.hash(j + 1, n);
							h31 += pow31[n - j - 1] * (str.charAt(i) - 'a' + 1);
							h31 %= mod;
							h31 += pow31[n - j] * hash31.hash(i + 1, j - 1);
							h31 %= mod;
							h31 += pow31[n - i - 1] * (str.charAt(j) - 'a' + 1);
							h31 %= mod;
							h31 += pow31[n - i] * hash31.hash(0, i - 1);
							h31 %= mod;
							h61 += pow61[n - j - 1] * (str.charAt(i) - 'a' + 1);
							h61 %= mod;
							h61 += pow61[n - j] * hash61.hash(i + 1, j - 1);
							h61 %= mod;
							h61 += pow61[n - i - 1] * (str.charAt(j) - 'a' + 1);
							h61 %= mod;
							h61 += pow61[n - i] * hash61.hash(0, i - 1);
							h61 %= mod;
							long c = 1l * h31 * mod + h61;
							hs.add(c);
							//pw.println(h31 + " " + h61);
							if(s == 0)
								combo.put(c, i * 2600 + j);
						}
						//pw.println(pow31[n - j - 1] * (str.charAt(i) - 'a' + 1));
						//pw.println(pow31[n - j] * hash31.hash(i + 1, j - 1));
						//pw.println(pow31[n - i - 1] * (str.charAt(j) - 'a' + 1));
						//pw.println(pow31[n - i] * hash31.hash(0, i - 1) + "d");
					}
				}
				for(long x : hs) keep.put(x, keep.getOrDefault(x, 0) + 1);
			}
			
			for(long x : keep.keySet()) {
				if(keep.get(x) == k) {
					int i = combo.get(x) / 2600;
					int j = combo.get(x) % 2600;
					char[] arr = first.toCharArray();
					char temp = arr[i];
					arr[i] = arr[j];
					arr[j] = temp;
					pw.println(new String(arr));
					return;
				}
			}
			if(n == 2500) {
				pw.println(keep);
			}
			pw.println(-1);
		}
		class CharHash {
	        private int MOD = (int) (1e9 + 7);
	        private int[] inverse;
	        private int[] hash;
	        private int n;
	        private int x;
	 
	        public CharHash(char[] data, int x) {
	            n = data.length;
	            inverse = new int[n];
	            this.x = x;
	            inverse[0] = 1;
	            long inv = pow(x, MOD - 2);
	            for (int i = 1; i < n; i++) {
	                this.inverse[i] = (int) (this.inverse[i - 1] * inv % MOD);
	            }
	 
	            hash = new int[n];
	            hash[n - 1] = data[n - 1] - 'a' + 1;
	            long baseInc = 1;
	            for (int j = n - 2; j >= 0; j--) {
	                baseInc = baseInc * x % MOD;
	                int dataval = data[j] - 'a' + 1;
	                hash[j] = (int) (((long) hash[j + 1] + dataval * baseInc) % MOD);
	            }
	        }
	 
	        public long pow(int x, int n) {
	            int bit = 31 - Integer.numberOfLeadingZeros(n);
	            long product = 1;
	            for (; bit >= 0; bit--) {
	                product = product * product % MOD;
	                if (((1 << bit) & n) != 0) {
	                    product = product * x % MOD;
	                }
	            }
	            return product;
	        }
	 
	        public int hash(int l, int r) {
	            if(l > r || l == n) return 0;
	            long hash = this.hash[l];
	            if (r < n - 1) {
	                hash = hash - this.hash[r + 1];
	                if (hash < 0) {
	                    hash += MOD;
	                }
	                hash = hash * inverse[n - 1 - r] % MOD;
	            }
	            return (int) hash;
	        }
        }
	}
	static long binpow(long a, long b, long m) {
		a %= m;
		long res = 1;
		while (b > 0) {
			if ((b & 1) == 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
	}
	static void sort(int[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static void sort(long[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static class tup implements Comparable<tup>{
		int a, b;
		tup(int a,int b){
			this.a=a;
			this.b=b;
		}
		@Override
		public int compareTo(tup o){
			return Integer.compare(o.b,b);
		}
	}
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(i + 1);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(i + 1);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}