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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;


import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.TreeSet;


public final class CF_Ed34_Ev2{

	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}


	static class BIT {

		long[] tree;
		int N;

		BIT(int N){
			tree=new long[N+1];
			this.N=N;
		}

		void add(int idx,int val){
			idx++;
			while (idx<=N){
				tree[idx]+=val;
				idx+=idx & (-idx);
			}
		}
		long read(int idx){
			idx++;
			long sum=0;
			while (idx>0){
				sum+=tree[idx];
				idx-=idx & (-idx);
			}
			return sum;
		}

	}


	// f(n,x,y) = sum f(n1,x1,y1)*f(n2,x2,y2) with n1+n2=n and pgcd(x1,x2)=x and y1+y2=y
	// this is double convolution on y and n

	static ArrayList<ArrayList<Integer>> generatePermutations(ArrayList<Integer> items){
		ArrayList<ArrayList<Integer>> globalRes=new ArrayList<ArrayList<Integer>>();
		if (items.size()>1) {
			for (Integer item:items){

				ArrayList<Integer> itemsTmp=new ArrayList<Integer>(items);
				itemsTmp.remove(item);
				ArrayList<ArrayList<Integer>> res=generatePermutations(itemsTmp);
				for (ArrayList<Integer> list:res){
					list.add(item);
				}
				globalRes.addAll(res);
			}
		}
		else {
			Integer item=items.get(0);
			ArrayList<Integer> list=new ArrayList<Integer>();
			list.add(item);
			globalRes.add(list);
		}

		return globalRes;
	}

	static long solve(int x,int y){

		return 0;
	}

	static long mod=1000000007;


	// Global vars
	static BufferedWriter out;
	static InputReader reader;




	static void process() throws Exception {


		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader=new InputReader(System.in);

		int k=reader.readInt();
		int n=reader.readInt();
		
		HashSet<String> hs=new HashSet<String>();
		for (int i=0;i<k;i++)
			hs.add(reader.readString());
		k=hs.size();
		String[] map=new String[k];
		int st=0;
		for (String s:hs)
			map[st++]=s;
		
		String ans="-1";
		ArrayList<Integer> lost=new ArrayList<Integer>();

		if (k==1){

			char[] cc=map[0].toCharArray();
			char d=cc[0];
			cc[0]=cc[1];
			cc[1]=d;
			ans=new String(cc);

		} else {
			int CX=26;
			int dn=0;
			int[] target=new int[n];

			int[] num=new int[CX];
			for (int i=0;i<n;i++){
				char c=map[0].charAt(i);
				num[c-'a']++;
			}

			boolean db=false;
			for (int x=0;x<CX;x++){
				if (num[x]>1)
					db=true;
			}

			boolean ko=false;
			int[][] sum=new int[n][CX];
			loop0:for (int u=0;u<n;u++) {
				int[] cnt=new int[CX];
				target[u]=-1;
				boolean allocated=false;
				for (int j=0;j<k;j++){
					int x=map[j].charAt(u)-'a';
					sum[u][x]++;
					//log(sum[u][x]);
					if (sum[u][x]*2>k){
						//log("majority for "+(char)(x+'a')+" at pos :"+u);
						if (!allocated){
							if (num[x]>0){
								target[u]=x;
								num[x]--;
								allocated=true;
								//log("allocating :"+(char)(x+'a')+" at position "+u);
							} else {
								//log("fail 1");
								ko=true;
								break loop0;
							}
						}
					}
				}
				if (target[u]==-1)
					lost.add(u);

			}




			char[] bbb=new char[n];
			for (int u=0;u<n;u++)
				bbb[u]=(char)(target[u]+'a');
			String tmp=new String(bbb);
			log(tmp);




			if (lost.size()>4)
				ko=true;
			if (!ko){


				ArrayList<Integer> cand=new ArrayList<Integer>();
				for (int x=0;x<CX;x++){
					while (num[x]>0){
						cand.add(x);
						num[x]--;
					}
				}


				//log(lost);
				//log(cand);
				ArrayList<ArrayList<Integer>> world=generatePermutations(cand);

				lp:for (ArrayList<Integer> lst:world){

					int C=lost.size();
					for (int i=0;i<C;i++){
						target[lost.get(i)]=lst.get(i);
					}


					boolean good=true;


					loop:for (int j=0;j<k;j++){
						int diff=0;
						for (int u=0;u<n;u++){
							int x=map[j].charAt(u)-'a';
							if (x!=target[u])
								diff++;
						}
						if (diff>2 || (diff==0 && db==false)){
							good=false;
							break loop;
						}
					}
					if (good) {
						char[] bb=new char[n];
						for (int u=0;u<n;u++)
							bb[u]=(char)(target[u]+'a');
						ans=new String(bb);
					}
					break lp;
				}

			}

		}


		output(ans);


		try {
			out.close();
		}
		catch (Exception E){}


	}


	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}


		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res=new StringBuilder();
			do {
				res.append((char)c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}




		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}


}