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.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class E
{
	static int k,n;
	static String[] arr;
	static int[] vis;
	static int vid;
	static boolean rep;
	static int[][] perm3, perm4;
	
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		perm3 = new int[6][3];
		perm4 = new int[24][4];
		
		perm3[0] = new int[]{0,1,2};
		perm4[0] = new int[]{0,1,2,3};
		
		for (int i = 1; i < 6; i++)
		{
			int[] nxt = Arrays.copyOf(perm3[i-1], 3);
			nextPermutation(nxt);
			perm3[i] = Arrays.copyOf(nxt, 3);
		}
		

		for (int i = 1; i < 24; i++)
		{
			int[] nxt = Arrays.copyOf(perm4[i-1], 4);
			nextPermutation(nxt);
			perm4[i] = Arrays.copyOf(nxt, 4);
		}
		
		
		vis = new int[26];
		k = sc.nextInt();
		n = sc.nextInt();
		TreeSet<String> set = new TreeSet<String>();
		for (int i = 0; i < k; i++)
			set.add(sc.next());
		
		if(set.size() == 1)
		{
			String s = set.first();
			pw.print(s.charAt(1));
			pw.print(s.charAt(0));
			pw.println(s.substring(2));
		}else
		{
			arr = new String[set.size()];
			int ind = 0;
			for (String s : set)
				arr[ind++] = s;
			int[] freq = new int[26];
			for (int i = 0; i < arr[0].length(); i++)
			{
				freq[arr[0].charAt(i)-'a']++;
				if(freq[arr[0].charAt(i)-'a'] > 1)
					rep = true;
			}
			for (int i = 0; i < arr.length; i++)
			{
				int[] tmp = new int[26];
				for (int j = 0; j < arr[i].length(); j++)
					tmp[arr[i].charAt(j)-'a']++;
				for (int j = 0; j < tmp.length; j++)
				{
					if(tmp[j] != freq[j])
					{
						System.out.println(-1);
						return;
					}
				}
			}
			ArrayList<String> cand = getC(arr[0], arr[1]);
			for (String cnd : cand)
			{
				if(ok(cnd))
				{
					pw.println(cnd);
					pw.flush();
					return;
				}
			}
			
			pw.println(-1);
		}
		
		
		
		pw.flush();
		pw.close();
	}
	
		
	private static ArrayList<String> getC(String s1, String s2)
	{
		ArrayList<String> res = new ArrayList<String>();
		boolean[] difInd = new boolean[s1.length()];
		int dif = 0;
		ArrayList<Character> diffCh = new ArrayList<Character>();
		for (int i = 0; i < s1.length(); i++)
		{
			if(s1.charAt(i) != s2.charAt(i))
			{
				dif++;
				difInd[i] = true;
				diffCh.add(s1.charAt(i));
			}
		}
		res.add(s1);
		res.add(s2);
		if(dif == 2)
		{
			res.add(s1);
			res.add(s2);
		}else
			if(dif == 3)
			{
				for (int i = 0; i < perm3.length; i++)
				{
					int ind = 0;
					StringBuilder sb = new StringBuilder();
					for (int j = 0; j < n; j++)
					{
						if(!difInd[j])
							sb.append(s1.charAt(j));
						else
						{
							sb.append(diffCh.get(perm3[i][ind++]));
						}
					}
					res.add(sb.toString());
				}
			}else if(dif == 4)
			{
				for (int i = 0; i < perm4.length; i++)
				{
					int ind = 0;
					StringBuilder sb = new StringBuilder();
					for (int j = 0; j < n; j++)
					{
						if(!difInd[j])
							sb.append(s1.charAt(j));
						else
						{
							sb.append(diffCh.get(perm4[i][ind++]));
						}
					}
					res.add(sb.toString());
				}
			}
		
		return res;
	}


	private static boolean ok(String cnd)
	{
		ArrayList<Integer> diffInd = new ArrayList<Integer>();
		for (int i = 0; i < arr.length; i++)
		{
			diffInd.clear();
			int diff = 0;
			for (int c = 0; c < n; c++)
			{
				if(cnd.charAt(c) != arr[i].charAt(c))
				{
					diff++;
					if(diffInd.size() < 3)
					{
						diffInd.add(c);
					}
				}
			}
			if(diff == 0 && rep)
				continue;
			if(diff == 2)
			{
				if(arr[i].charAt(diffInd.get(0)) == cnd.charAt(diffInd.get(1)) && arr[i].charAt(diffInd.get(1)) == cnd.charAt(diffInd.get(0)))
					continue;
			}
			return false;
		}
		return true;
	}
	
	static boolean nextPermutation(int[] c) 
	{
		// 1. finds the largest k, that c[k] < c[k+1]
		int first = getFirst(c);
		if(first == -1)
			return false;

		// 2. find last index toSwap, that c[k] < c[toSwap]
		int toSwap = c.length - 1;
		while (c[first] >= c[toSwap])
			--toSwap;

		// 3. swap elements with indexes first and last
		swap(c, first++, toSwap);

		// 4. reverse sequence from k+1 to n (inclusive) 
		toSwap = c.length - 1;
		while(first < toSwap)
			swap(c, first++, toSwap--);
		return true;
	}

	static int getFirst(int[] c) 
	{
		for ( int i = c.length - 2; i >= 0; i--)
			if (c[i] < c[i + 1])
				return i;
		return -1;
	}


	static void swap(int[] c,int i, int j) 
	{
		int tmp = c[i];
		c[i] = c[j];
		c[j] = tmp;
	}



	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s)
		{
			br = new BufferedReader(new InputStreamReader(s));
		}

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

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException
		{
			return br.readLine();
		}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else
				{
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException
		{
			return br.ready();
		}
	}
}
