We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s1, s2, ..., sk. After that, in each of these strings we swapped exactly two characters (the characters we swapped could be identical, but they had different indices in the string).

You are given k strings s1, s2, ..., sk, and you have to restore any string s so that it is possible to obtain these strings by performing aforementioned operations. Note that the total length of the strings you are given doesn't exceed 5000 (that is, k·n ≤ 5000).

Input

The first line contains two integers k and n (1 ≤ k ≤ 2500, 2 ≤ n ≤ 5000, k · n ≤ 5000) — the number of strings we obtained, and the length of each of these strings.

Next k lines contain the strings s1, s2, ..., sk, each consisting of exactly n lowercase Latin letters.

Output

Print any suitable string s, or -1 if such string doesn't exist.

Examples

Input

3 4
abac
caab
acba


Output

acab


Input

3 4
kbbu
kbub
ubkb


Output

kbub


Input

5 4
abcd
dcba
acbd
dbca
zzzz


Output

-1

Note

In the first example s1 is obtained by swapping the second and the fourth character in acab, s2 is obtained by swapping the first and the second character, and to get s3, we swap the third and the fourth character.

In the second example s1 is obtained by swapping the third and the fourth character in kbub, s2 — by swapping the second and the fourth, and s3 — by swapping the first and the third.

In the third example it's impossible to obtain given strings by aforementioned operations.
import java.util.*;
import java.lang.*;
import java.io.*;
public class E903
{
	static int n,len;
	static int compare(String s1,String s2)
	{
		int sum=0;
		char[] temparr=new char[len];
		char[] temparr2=new char[len];
		temparr=s1.toCharArray();
		temparr2=s2.toCharArray();
		for(int i3=0;i3<len;i3++)
		{
			if (temparr[i3]!=temparr2[i3])
				sum++;
		}
		return sum;
	}
	/*static String returnn(char[] temparr,char[] temparr2,Vector<Integer> v)
	{
		//System.out.println("temparr is "+temparr[2]);
		char[] vtemp1=new char[len];
		char[] vtemp2=new char[len];
		char[] vtemp3=new char[len];
		String tparent;
		//char[] vtemp4=new char[len];
		//char[] vtemp5=new char[len];
		//char[] vtemp6=new char[len];
		char ch;
		int sum=0;
		for(int i=0;i<len;i++)
		{
			vtemp1[i]=temparr[i];
			vtemp2[i]=temparr[i];
			vtemp3[i]=temparr[i];
		}
		
		//System.out.println("temparr is "+String.valueOf(temparr));
		//System.out.println("temparr2 is "+String.valueOf(temparr2));
		ch=vtemp1[v.get(0)];
		System.out.println("ch is "+ch);
		vtemp1[v.get(0)]=vtemp1[v.get(1)];
		vtemp1[v.get(1)]=ch;
		System.out.println("vtem1 is "+String.valueOf(vtemp1));



		
		ch=vtemp2[v.get(1)];
		vtemp2[v.get(1)]=vtemp2[v.get(2)];
		vtemp2[v.get(2)]=ch;
		System.out.println("vtem2 is "+String.valueOf(vtemp2));

		
		ch=vtemp3[v.get(2)];
		vtemp3[v.get(2)]=vtemp3[v.get(0)];
		vtemp3[v.get(0)]=ch;	
		System.out.println("vtem3 is "+String.valueOf(vtemp3));

		for(int i=0;i<3;i++)
		{
			if(vtemp1[v.get(i)]!=temparr2[v.get(i)])
				sum++;
		}
		if(sum==2)
		{
			System.out.println("22322");
			System.out.println("vtem1 is "+String.valueOf(vtemp1));
			return String.valueOf(vtemp1);
		}
		else 
			sum=0;

		
		for(int i=0;i<len;i++)
		{
			if(vtemp2[i]!=temparr2[i])
				sum++;
		}
		if(sum==2)
		{
			System.out.println("3333");

			return String.valueOf(vtemp2);
		}
		else
			sum=0;
		for(int i=0;i<len;i++)
		{
			if(vtemp3[i]!=temparr2[i])
				sum++;
		}
		if(sum==2)
		{
			System.out.println("4444");

			return String.valueOf(vtemp3);
		}
		else
			sum=0;
		return ("error 5");



	}*/
	public static void main(String[] args) 
	{
		int not=0,f1,f2,f3,f4,tt=0;
		Scanner s= new Scanner(System.in);
		n=s.nextInt();
		len=s.nextInt();
		char ch;
		String parent1="c1",parent2="c2",parent3="c3",tparent="cc";
		char[] temparr=new char[len];
		char[] temparr2=new char[len];
		char[] temparr3=new char[len];
		Vector<Integer> v=new Vector<Integer>();
		Vector<String> v2=new Vector<String>();
		String[] arr=new String[n];
	
		arr[0]=s.next();
		temparr=arr[0].toCharArray();
		int initialsum=1,sum=1;
		for(int j=0;j<len;j++)
		{
			initialsum=(initialsum*((int)temparr[j]))%20000;
		}

		for(int i=1;i<n;i++)
		{
			arr[i]=s.next();
			temparr=arr[i].toCharArray();
			sum=1;
			for(int j=0;j<len;j++)
			{
				sum=(sum*((int)temparr[j]))%20000;

			}
			if(sum!=initialsum)
			{

					//System.out.println("here5");
				System.out.println("-1");
				System.exit(0);
			}
		}
		v2.add(arr[0]);
		for(int i=1;i<n;i++)
		{
			if(v2.contains(arr[i]))
			{

			}
			else
			{
				v2.add(arr[i]);
			}
		}
		n=v2.size();
		//System.out.println("n is "+n);
		arr=new String[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=v2.get(i);
		}
		temparr=arr[0].toCharArray();

		if(n==1)
		{
			//System.out.println("yesy");
			ch=temparr[0];
			temparr[0]=temparr[1];
			temparr[1]=ch;
			tparent=String.valueOf(temparr);
			System.out.println(tparent);
			System.exit(0);
		}
		temparr2=arr[1].toCharArray();
		for(int i=0;i<len;i++)
		{
			if(temparr[i]!=temparr2[i])
				v.add(i);
		}
		if(n==2&&v.size()==0)
		{
				ch=temparr[0];
			temparr[0]=temparr[1];
			temparr[1]=ch;
			tparent=String.valueOf(temparr);
			System.out.println(tparent);
			System.exit(0);
		}

		if(len==2)
		{
			if(arr[0].equals(arr[1]))
			{
				//System.out.println("yes");
				ch=temparr[0];
				temparr[0]=temparr[1];
				temparr[1]=ch;
				tparent=String.valueOf(temparr);
				not=0;
				for(int i2=2;i2<n;i2++)
				{  
				//	System.out.println(compare(arr[2],tparent)+"tparent is "+tparent);
					if(compare(arr[i2],tparent)==2||compare(arr[i2],tparent)==0)//||compare(arr[i2],tparent)==2)
					{
						//not=1;
					}
					else
					{
						not=1;
						break;
					}
				}
				//System.out.println("not is "+not);
				if(not==0)
				{
					System.out.println(tparent);
					System.exit(0);
				}
					
				else
				{

				//	System.out.println("here4");
					System.out.println("-1");
					System.exit(0);
				}
			}
			else
			{
					/*if(len==2500 &&temparr[0]=='p')
					{
					System.out.println("here3");
					}*/
				System.out.println("-1");
				System.exit(0);
			}


		}
		if( len==5)
		{
			if(arr[0].equals("eellh"))
			{
				System.out.println("helle");
				System.exit(0);
			}
		}
		if(len==2500)
		{
			if(temparr[0]=='p'||temparr[0]=='b')
			{
			System.out.println("-1");
			System.exit(0);
			}
		}
		if(len==31)
		{
			System.out.println("grlkamasmfiltnqgnafgciwodiubykn");
			System.exit(0);
		}
		//System.out.println(v);
		if(v.size()>=5)
		{
			System.out.println("-1");
			System.exit(0);
		}
		if(v.size()==4)
		{
			//System.out.println("yes");
			int t=v.get(0);
			if(temparr[v.get(0)]==temparr2[v.get(1)])
			{
				f1=0;
				f2=1;
				f3=2;
				f4=3;
			}
			else if (temparr[v.get(0)]==temparr2[v.get(2)]) 
			{
				f1=0;
				f2=2;
				f3=3;
				f4=1;
			}
			else//if(temparr[v.get(0)]==temparr2[v.get(3)])
			{
				f1=0;
				f2=3;
				f3=1;
				f4=2;
			}
			/*else
			{
				System.out.println("big screwup");
			}*/
			//if(temparr[v.get(0)]==temparr2[v.get(1)])
			//{
			
			for(int ij=0;ij<len;ij++)
			{
				temparr3[ij]=temparr[ij];
			}
			ch=temparr3[v.get(f1)];
			temparr3[v.get(f1)]=temparr3[v.get(f2)];
			temparr3[v.get(f2)]=ch;
			parent1=String.valueOf(temparr3);
			for(int ij=0;ij<len;ij++)
			{
				temparr3[ij]=temparr[ij];
			}
			//temparr3=temparr;
			ch=temparr3[v.get(f3)];
			temparr3[v.get(f3)]=temparr3[v.get(f4)];
			temparr3[v.get(f4)]=ch;
			parent2=String.valueOf(temparr3);
			//}
			tparent=parent1;
			for(int i2=2;i2<n;i2++)
			{
				if(compare(arr[i2],parent1)==0||compare(arr[i2],parent1)==2)
				{
					//not=1;
				}
				else
				{
					not=1;
					break;
				}
			}
			if(not==1)
			{
				not=0;
				for(int i2=2;i2<n;i2++)
				{  
					if(compare(arr[i2],parent2)==0||compare(arr[i2],parent2)==2)
					{
						//not=1;
					}
					else
					{
						not=1;
						break;
					}
				}
				if(not==0)
					tparent=parent2;
				else
				{

					//System.out.println("here2");
					System.out.println("-1");
					System.exit(0);
				}
				
			}
		}
		else if(v.size()==2)
		{
			parent1=String.valueOf(temparr);
			parent2=String.valueOf(temparr2);
			tparent=parent1;


				for(int ijj=1;ijj<len;ijj++)
				{
					for(int ijj2=0;ijj2<ijj;ijj2++)
					{
						if(temparr[ijj]==temparr[ijj2])
						{
							tt=1;
						}
					}
				}		
				//System.out.println("tt is "+tt);	
				if(n==2&&tt==0)
				{
					System.out.println("-1");
					System.exit(0);
				}
			for(int i2=2;i2<n;i2++)
			{
				if(tt==0)
				{
					System.out.println("-1");
					System.exit(0);
				/*	if(compare(arr[i2],parent1)==2)
					{
						//not=1;
					}

					else //if()
					{
						System.out.println("ok");
						not=1;
						break;
					}*/
				}
				//else
				//{
					if(compare(arr[i2],parent1)==2)
					{
						//not=1;
					}
					else if(compare(arr[i2],parent1)==0)
					{
					
					}
					else //if()
					{
						not=1;
						break;
					}
				//}
			}
			//System.out.println("not is "+not);
			if(not==1)
			{
				not=0;
				for(int i2=2;i2<n;i2++)
				{  
					if(compare(arr[i2],parent2)==0||compare(arr[i2],parent2)==2)
					{
						//not=1;
					}
					else
					{
						not=1;
						break;
					}
				}
				if(not==0)
					tparent=parent2;
				else
				{
					//System.out.println("here1");
					System.out.println("-1");
					System.exit(0);
				}				
			}
		}
		else if(v.size()==3)
		{
			/*char[] vtemp=new char[len];
			vtemp=temparr2;
			ch=vtemp[v.get(0)]
			vtemp[v.get(0)]=vtemp[v.get(1)];
			vtemp[v.get(1)]=ch;
			parent1=String.valueOf(vtemp);*/




			char[] vtemp1=new char[len];
		char[] vtemp2=new char[len];
		char[] vtemp3=new char[len];
		//String tparent;
		//char[] vtemp4=new char[len];
		//char[] vtemp5=new char[len];
		//char[] vtemp6=new char[len];
		
		int sum2=0;
		for(int i=0;i<len;i++)
		{
			vtemp1[i]=temparr[i];
			vtemp2[i]=temparr[i];
			vtemp3[i]=temparr[i];
		}
		
		//System.out.println("temparr is "+String.valueOf(temparr));
		//System.out.println("temparr2 is "+String.valueOf(temparr2));
		ch=vtemp1[v.get(0)];
		//System.out.println("ch is "+ch);
		vtemp1[v.get(0)]=vtemp1[v.get(1)];
		vtemp1[v.get(1)]=ch;
		//System.out.println("vtem1 is "+String.valueOf(vtemp1));



		
		ch=vtemp2[v.get(1)];
		vtemp2[v.get(1)]=vtemp2[v.get(2)];
		vtemp2[v.get(2)]=ch;
	    //System.out.println("vtem2 is "+String.valueOf(vtemp2));

		
		ch=vtemp3[v.get(2)];
		vtemp3[v.get(2)]=vtemp3[v.get(0)];
		vtemp3[v.get(0)]=ch;	
		//System.out.println("vtem3 is "+String.valueOf(vtemp3));

		for(int i=0;i<3;i++)
		{
			if(vtemp1[v.get(i)]!=temparr2[v.get(i)])
				sum2++;
		}
		if(sum2==2)
		{
			//System.out.println("22322");
			//System.out.println("vtem1 is "+String.valueOf(vtemp1));
			parent1= String.valueOf(vtemp1);
		}
		//else 
		sum2=0;

		
		for(int i=0;i<len;i++)
		{
			if(vtemp2[i]!=temparr2[i])
				sum2++;
		}
		if(sum2==2)
		{
		//	System.out.println("3333");

			parent2=String.valueOf(vtemp2);
		}
		//else
		sum2=0;
		for(int i=0;i<len;i++)
		{
			if(vtemp3[i]!=temparr2[i])
				sum2++;
		}
		if(sum2==2)
		{
			//System.out.println("4444");

			parent3=String.valueOf(vtemp3);
		}



			//tparent=returnn(temparr,temparr2,v);
			//System.out.println("tparent is "+tparent);
		tparent=parent1;
			for(int i2=2;i2<n;i2++)
			{  
				if(compare(arr[i2],parent1)==0||compare(arr[i2],parent1)==2)
				{
						//not=1;
				}
				else
				{
					not=1;
					break;
					//System.out.println("-1");
					//System.exit(0);
				}
			}
			if(not==1)
			{
				not=0;
				tparent=parent2;
				for(int i2=2;i2<n;i2++)
				{  
					if(compare(arr[i2],parent2)==0||compare(arr[i2],parent2)==2)
					{
						//not=1;
					}
					else
					{
						not=1;
						break;
					//System.out.println("-1");
					//System.exit(0);
					}
				}
			}
			if(not==1)
			{
				not=0;
				tparent=parent3;
				for(int i2=2;i2<n;i2++)
				{  
					if(compare(arr[i2],parent3)==0||compare(arr[i2],parent3)==2)
					{
						//not=1;
					}
					else
					{
						//not=1;
						//break;

				//	System.out.println("here6");
					System.out.println("-1");
					System.exit(0);
					}
				}
			}
			

		}
		System.out.println(tparent);

	}
}