We had a string *s* consisting of *n* lowercase Latin letters. We made *k* copies of this string, thus obtaining *k* identical strings *s*<sub class="lower-index">1</sub>, *s*<sub class="lower-index">2</sub>, ..., *s*<sub class="lower-index">*k*</sub>. 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 *s*<sub class="lower-index">1</sub>, *s*<sub class="lower-index">2</sub>, ..., *s*<sub class="lower-index">*k*</sub>, 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).
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 *s*<sub class="lower-index">1</sub>, *s*<sub class="lower-index">2</sub>, ..., *s*<sub class="lower-index">*k*</sub>, each consisting of exactly *n* lowercase Latin letters.
In the first example *s*<sub class="lower-index">1</sub> is obtained by swapping the second and the fourth character in acab, *s*<sub class="lower-index">2</sub> is obtained by swapping the first and the second character, and to get *s*<sub class="lower-index">3</sub>, we swap the third and the fourth character.

In the second example *s*<sub class="lower-index">1</sub> is obtained by swapping the third and the fourth character in kbub, *s*<sub class="lower-index">2</sub> — by swapping the second and the fourth, and *s*<sub class="lower-index">3</sub> — by swapping the first and the third.

In the third example it's impossible to obtain given strings by aforementioned operations.
3 4
abac
caab
acba
acab
3 4
kbbu
kbub
ubkb
kbub
5 4
abcd
dcba
acbd
dbca
zzzz
-1
3 2
xh
xh
xh
hx
3 4
kbub
kbbu
ubkb
kbub
1 2
yu
uy
1 3
vts
tvs
2 2
nm
nm
mn
2 3
ghn
ghn
hgn
3 2
cg
cg
cg
gc
3 3
uvh
vhu
huv
vuh
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
zq
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
szk
2 6
abcdef
badcef
bacdef
5 5
eellh
ehlle
ehlle
helle
hlele
helle
5 5
zbibx
zbbix
zbibx
xbibz
xbibz
zbibx
5 5
gyvnn
gnvny
vygnn
gynvn
gnvny
gyvnn
2 4
abcd
ccdc
-1
2 2
ab
cd
-1
2 4
ayax
abac
-1
2 4
ajax
azad
-1
2 3
abc
abz
-1
8 6
mnionk
mnikno
inmkno
mnnkio
oniknm
oniknm
mkinno
mnikon
mnikno
8 23
mgiomcytqdvoihhcirldmuj
mgmoicytqdvoihhicrldmuj
mgmomcytqdvoihhicrldiuj
mgcomcytqdvoihhiirldmuj
mgiimcytqdvoihhocrldmuj
mgioicytqdvoihhmcrldmuj
mgiomcytqdvodhhicrlimuj
mgiomcytjdvoihhicrldmuq
mgiomcytqdvoihhicrldmuj
2 5
dbcag
acbdh
-1
2 2
ac
ca
-1
2 16
hmlqgaepsgpdbzyk
chhhburuvnyirrim
-1
def check(s,t):
  diff=[]
  cnt=[0]*26
  for i in range(m):
    if s[i]!=t[i]:
      diff.append(i)
      if len(diff)>2:
        return False
    cnt[ord(s[i])-97]+=1
  if len(diff)==0:
    if max(cnt)>=2:
      return True
    return False
  if len(diff)==1:
    return False
  x,y=diff[0],diff[1]
  if s[x]==t[y] and t[x]==s[y]:
    return True
  return False

def calc(i,j):
  T=S[0].copy()
  T[i],T[j]=T[j],T[i]
  for k in range(1,n):
    if not check(S[k],T):
      return
  print(''.join(T))
  exit()

n,m=map(int,input().split())
S=[]
for i in range(n):
  S.append(list(input()))

for i in range(m):
  for j in range(i+1,m):
    calc(i,j)

print(-1)