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

public class Solution {
	static long MOD = 1000000007;
	
	static long calculateHash(char[] str, int n, long prime) {
		long hash = 1;
		
		for(int i=0;i<n;i++) {
			hash = hash*prime + (long)(str[i]-96);
			hash+=MOD;
			hash%=MOD;
		}
		return hash;
	}
	
	public static void main(String[] args) throws Exception{
		InputReader in = new InputReader(System.in);
		
		int k = in.nextInt();
		int n = in.nextInt();
		
		HashMap<Long,Integer> map1= new HashMap<Long, Integer>();
		HashMap<Long,Integer> map2= new HashMap<Long, Integer>();
		
		long baseHash1 = 0;
		long baseHash2 = 0;
		char[] baseStr = new char[n];
		for(int i=0;i<k;i++) {
			char[] str = in.next().toCharArray();
			long hash1 = calculateHash(str,n,259L);
			long hash2 = calculateHash(str,n,47L);
			if(i==0){
				baseHash1 = hash1;
				baseHash2 = hash2;
				baseStr = str;
			}
			map1.put(hash1, 1);
			map2.put(hash2, 1);
		}
		
		
		boolean flag = false;
		char[] rslt = new char[n];
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				long val1 = baseStr[i]-96;
				long val2 = baseStr[j]-96;
				
				long diff1 = power(259L,(long)(n-i-1));
				diff1-=power(259L,(long)n-j-1);
				diff1+=MOD;
				diff1%=MOD;
				if(val1<val2) {
					diff1=(-1L)*diff1;
				}
				diff1*=Math.abs(val2-val1);
				
				long tempHash1 = baseHash1+diff1;
				tempHash1+=MOD;
				tempHash1%=MOD;
				
				long diff2 = power(47L,(long)(n-i-1));
				diff2-=power(47L,(long)n-j-1);
				diff2+=MOD;
				diff2%=MOD;
				if(val1<val2) {
					diff2=(-1L)*diff2;
				}
				diff2*=Math.abs(val2-val1);
				
				long tempHash2 = baseHash2+diff2;
				tempHash2+=MOD;
				tempHash2%=MOD;
				
				if(map1.get(tempHash1)==null && map2.get(tempHash2)==null) {
					for(int t=0;t<n;t++) {
						if(t==i) {
							rslt[t] = baseStr[j];
						} else if(t==j) {
							rslt[t] = baseStr[i];
						} else {
							rslt[t] = baseStr[t];
						}
					}
					flag = true;
					break;
				}
			}
			if(flag) {
				break;
			}
		}
		
		if(!flag) {
			System.out.println(-1);
		} else {
			System.out.println(rslt);
		}
	}
	
	public static void MergeSort(int[] A, int lo, int hi) {
		if(lo<hi) {
			int mid = (lo+hi)/2;
			MergeSort(A,lo,mid);
			MergeSort(A,mid+1,hi);
			Merge(A,lo,mid,hi);
		}
	}
	
	public static void Merge(int[] A, int lo, int mid, int hi) {
		int p = lo, q = mid+1;
		
		int[] Arr = new int[hi-lo+1];
		int k = 0;
		
		for(int i=lo;i<=hi;i++) {
			if(p>mid) {
				Arr[k++] = A[q++];
			} else if(q>hi) {
				Arr[k++] = A[p++];
			} else if(A[p]<A[q]) {
				Arr[k++] = A[p++];
			} else {
				Arr[k++] = A[q++];
			}
		}
		
		for(int i=0;i<k;i++) {
			A[lo++] = Arr[i];
		}
	}
	
	public static void QuickSort(int[] A, int lo, int hi) {
		if(lo<hi) {
			int index = partition(A,lo, hi);
			QuickSort(A, lo, index-1);
			QuickSort(A, index+1, hi);
		}
	}
	
	public static int partition(int[] A, int lo, int hi) {
		int pivot = A[hi];
		
		int i = lo-1;
		
		for(int j=lo;j<hi;j++) {
			if(A[j]<=pivot) {
				i++;
				swap(A,i,j);
			}
		}
		swap(A,i+1,hi);
		return i+1;
	}
	
	public static void swap(int[] A, int i, int j) {
		int temp = A[i];
		A[i] = A[j];
		A[j] = temp;
	}
	
	//Search for A particular Key in a sorted array
	public static int binarySearch(int[] A, int key, int lo, int hi) {
		while(lo<=hi) {
			int mid = (lo+hi)/2;
			if(A[mid]==key) {
				return mid;
			} else if(A[mid]>key) {
				hi = mid-1;
			} else {
				lo = mid+1;
			}
		}
		return -1;
	}
	
	public static int upperBound(int[] A, int key, int lo, int hi) {
		while(lo<=hi) {
			int mid = (lo+hi)/2;
			if(A[mid]>key && (mid==1 || A[mid-1]<=key)) {
				return mid;
			} else if(A[mid]>key) {
				hi = mid-1;
			} else {
				lo = mid+1;
			}
		}
		return -1;
	}
	
	public static int lowerBound(int[] A, int key, int lo, int hi) {
		while(lo<=hi) {
			int mid = (lo+hi)/2;
			if(A[mid]>=key && (mid==1 || A[mid-1]<key)) {
				return mid;
			} else if(A[mid]>=key) {
				hi = mid-1;
			} else {
				lo = mid+1;
			}
		}
		return -1;
	}
	
	public static long power(long x, long n) {
		if(n==0) {
			return 1;
		}
		if(n==1) {
			return x;
		}
		long ret = (power(x,n/2)+MOD)%MOD;
		long val = (ret*ret+MOD)%MOD;
		if(n%2==1) {
			val*=x;
			val+=MOD;
			val%=MOD;
		}
		return val;
	}
	
	public static boolean check(int N, int pos) {
		return (N&(1<<pos))!=0;
	}
	
	public static int set(int N, int pos) {
		return N|=(1<<pos);
	}
	
	public static int[] sieve(int N) {
		int[] status = new int[(N>>5)+2];
		int sqrtN = (int)Math.sqrt(N);
		for(int i=3;i<=sqrtN;i+=2) {
			if(!check(status[i>>5],i&31)) {
				for(int j=i*i;j<=N;j+=(i<<1)) {
					status[j>>5] = set(status[j>>5],j&31);
				}
			}
		}
		
		int[] prime = new int[N];
		int cnt=0;
		prime[cnt++]=2;
		for(int i=3;i<=N;i+=2) {
			if(!check(status[i>>5],i&31)) {
				prime[cnt++]=i;
			}
		}
		return prime;
	}
	
	public static int[][] sparseTable(int[] A, int n) {
		int logN = (int)(Math.log(n)/Math.log(2));
		
		int[][] M = new int[n][logN+1];
		
		for(int i=0;i<n;i++) {
			M[i][0] = i;
		}
		
		for(int j=1;(1<<j)<=n;j++) {
			for(int i=0;i+(1<<j)-1<n;i++) {
				if(A[M[i][j-1]]<A[M[i+(1<<(j-1))][j-1]]) {
					M[i][j] = M[i][j-1];
				} else {
					M[i][j] = M[i+(1<<(j-1))][j-1];
				}
			}
		}
		
		return M;
	}
	
	public static void initialize(int[] A, int[] segmentTree, int start, int end, int index) {
		if(start==end) {
			segmentTree[index] = start;
			return;
		}
		
		int mid = (start+end)/2;
		
		initialize(A,segmentTree, start, mid, index*2+1);
		initialize(A,segmentTree, mid+1, end, index*2+2);
		
		if(A[segmentTree[index*2+1]]<=A[segmentTree[index*2+2]]) {
			segmentTree[index] = segmentTree[index*2+1];
		} else {
			segmentTree[index] = segmentTree[index*2+2];
		}
	}
	
	public static void update(int[] A, int[] segmentTree, int start, int end, int index, int pos, int val) {
		if(start==end) {
			A[segmentTree[index]] = val;
			return;
		}
		
		int mid = (start+end)/2;
		
		if(pos<=mid) {
			update(A,segmentTree,start,mid,index*2+1,pos,val);
		} else {
			update(A,segmentTree,mid+1,end,index*2+2,pos,val);
		}
		
		if(A[segmentTree[index*2+1]]<=A[segmentTree[index*2+2]]) {
			segmentTree[index] = segmentTree[index*2+1];
		} else {
			segmentTree[index] = segmentTree[index*2+2];
		}
	}
	
	public static int query(int[] A, int[] segmentTree, int start, int end, int index, int rangeStart, int rangeEnd) {
		if(rangeStart>end || rangeEnd<start) {
			return -1;
		}
		if(rangeStart<=start && rangeEnd>=end) {
			return segmentTree[index];
		}
		
		int mid = (start+end)/2;
		int val1 = query(A,segmentTree, start, mid, index*2+1, rangeStart, rangeEnd);
		int val2 = query(A,segmentTree, mid+1, end, index*2+2, rangeStart, rangeEnd);
		
		if(val1==-1) {
			return val2;
		} 
		if(val2==-1) {
			return val1;
		}
		if(A[val1]<=A[val2]) {
			return val1;
		}
		return val2;
	}
	
	public static void constructSegmentTree(int[] A, int n) {
		int x = (int)Math.ceil(Math.log(n)/Math.log(2));
		
		int size = (int)Math.pow(2,x+1)-1;
		
		int[] segmentTree = new int[size+1];
		initialize(A,segmentTree,0,n-1,0);
		//update
		update(A,segmentTree,0,n-1,0,4,10);
		
		//query
		int ret = query(A,segmentTree,0,n-1,0,9,9);
	}
	
	public static int[][][] FibonacciGeneration(int P) {
		int[][][] A = new int[P][2][2];
		A[0][0][0] = 1;
		A[0][0][1] = 1;
		A[0][1][0] = 1;
		A[0][1][1] = 0;
		
		for(int i=1;i<P;i++) {
			A[i][0][0] = A[i-1][0][0]*A[i-1][0][0] + A[i-1][0][1]*A[i-1][1][0];
			A[i][0][1] = A[i-1][0][0]*A[i-1][0][1] + A[i-1][0][1]*A[i-1][1][1];
			A[i][1][0] = A[i-1][1][0]*A[i-1][0][0] + A[i-1][1][1]*A[i-1][1][0];
			A[i][1][1] = A[i-1][1][0]*A[i-1][0][1] + A[i-1][1][1]*A[i-1][1][1];
		}
		return A;
	}
	
	public static int[][] matrixMultiplication(int[][] A, int[][] B) {
		int ARow = A.length;
		int ACol = A[0].length;

		int BCol = B[0].length;
		
		int[][] C = new int[ARow][BCol];
		
		for(int i=0;i<ARow;i++) {
			for(int j=0;j<BCol;j++) {
				C[i][j]=0;
				for(int k=0;k<ACol;k++) {
					C[i][j] += A[i][k]*B[k][j];
				}
			}
		}
		return C;
	}
	
	
	public static void Fibonacci() {
		//Array Size
		int N = 1000000001;
		//highest 2 power which is less than N
		int P = (int)Math.ceil(Math.log(N)/Math.log(2));
		//A contains fibonacci matrix for the power of 2's
		int[][][] A = FibonacciGeneration(P);
		
		//Lth Fibonacci(T=L-1)
		int T = 6;
		int[][] rs = {{1,0},{0,1}};
		
		for(int i=P-1;i>=0;i--) {
			if((T&(1<<i))!=0) {
				rs = matrixMultiplication(rs,A[i]);
			}
		}
		
		int rslt = rs[0][0] + rs[0][1];
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		
		public String next() throws Exception {
			while(tokenizer==null || !tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}
		
		public String nextLine() throws Exception {
			return reader.readLine();
		}
		
		public int nextInt() throws Exception {
			return Integer.parseInt(next());
		}
		
		public long nextLong() throws Exception {
			return Long.parseLong(next());
		}
		
		public double nextDouble() throws Exception {
			return Double.parseDouble(next());
		}
	}
}
