A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.

You are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substrings of this string. Restore the non-empty good string with minimum length. If several such strings exist, restore lexicographically minimum string. If there are no good strings, print "NO" (without quotes).

A substring of a string is a contiguous subsequence of letters in the string. For example, "ab", "c", "abc" are substrings of string "abc", while "ac" is not a substring of that string.

The number of occurrences of a substring in a string is the number of starting positions in the string where the substring occurs. These occurrences could overlap.

String *a* is lexicographically smaller than string *b*, if *a* is a prefix of *b*, or *a* has a smaller letter at the first position where *a* and *b* differ.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) — the number of strings in the set.

Each of the next *n* lines contains a non-empty string consisting of lowercase English letters. It is guaranteed that the strings are distinct.

The total length of the strings doesn't exceed 10<sup class="upper-index">5</sup>.
One can show that in the first sample only two good strings with minimum length exist: "cfmailru" and "mailrucf". The first string is lexicographically minimum.
4
mail
ai
lru
cf
cfmailru
3
kek
preceq
cheburek
NO
1
z
z
2
ab
ba
NO
2
ac
bc
NO
2
cd
ce
NO
2
ca
cb
NO
2
dc
ec
NO
26
hw
wb
ba
ax
xl
le
eo
od
dj
jt
tm
mq
qf
fk
kn
ny
yz
zr
rg
gv
vc
cs
si
iu
up
ph
NO
25
sw
wt
c
l
yo
ag
z
of
p
mz
nm
ui
zs
j
q
k
gd
b
en
x
dv
ty
h
r
vu
agdvuibcenmzswtyofhjklpqrx
2
az
zb
azb
26
l
q
b
k
h
f
x
y
j
a
i
u
s
d
c
g
v
w
p
o
m
t
r
z
n
e
abcdefghijklmnopqrstuvwxyz
76
amnctposz
mnctpos
os
u
e
am
amnc
eamnctpo
l
x
q
poszq
eamnc
ctposzq
ctpos
mnc
tpos
amnctposzql
tposzq
mnctposz
nctpos
ctposzql
amnctpos
mnct
p
ux
poszql
tpo
mnctposzql
mnctp
eamnctpos
amnct
tposzql
posz
z
ct
amnctpo
oszq
eamnct
tposz
s
mn
n
c
oszql
po
o
mnctposzq
t
amnctposzq
nctposzql
nct
amn
eam
ctp
osz
pos
mnctpo
zq
eamnctposzql
amnctp
szql
eamn
tp
zql
a
ea
ql
sz
eamnctposz
nctpo
ctposz
m
nctposz
nctp
nc
eamnctposzqlux
75
qsicaj
d
nkmd
db
tqsicaj
m
aje
ftqsicaj
caj
ftqsic
tqsicajeh
ic
pv
y
ho
icajeho
c
s
b
ftqsi
mdb
tqsic
tqs
si
nkmdb
jeh
ajeho
qs
tqsicajeho
je
wp
jeho
eh
wpv
h
o
yw
j
v
tqsicaje
ftqsicajeho
sica
cajeho
qsic
qsica
a
ftqsicajeh
n
tqsi
icajeh
sic
e
qsicaje
cajeh
ca
ft
sicajeho
ajeh
caje
qsicajeho
sicaje
ftqsicaje
sicajeh
ftqsica
ica
km
qsicajeh
aj
i
tq
md
kmdb
kmd
tqsica
nk
ftqsicajehonkmdbywpv
16
ngv
ng
jngvu
g
gv
vu
i
n
jngv
u
ngvu
jng
jn
l
j
gvu
ijngvul
33
aqzwlyfjcuktsr
gidpnvaqzwlyfj
vaqzwlyf
pnvaqzwlyfjcuktsrbx
jcuktsrbxme
uktsrb
hgidpnvaqzw
vaqzwlyfjcu
hgid
vaqzwlyfjcukts
pnvaqzwl
pnvaqzwlyfj
gidpnvaqzwlyfjcukt
aqzwlyfjcuktsrbxme
gidpnvaqzwlyfjcuktsrb
aqzw
lyfjcuktsrbxme
rbxm
wlyfjcukt
pnvaqzwlyfjcuktsr
nvaqzwly
d
zwlyf
hgidpnva
gidpnvaqzwlyfjcuktsrbxm
gidpn
fjcuktsrbxmeo
fjcuktsrbx
gidpnva
zwlyfjc
rb
tsrbxm
dpnvaqzwlyfjcuktsrbxm
hgidpnvaqzwlyfjcuktsrbxmeo
15
ipxh
ipx
r
xh
cjr
jr
p
ip
cj
i
x
hi
c
h
px
NO
51
p
su
bpxh
x
xhvacdy
qosuf
cdy
bpxhvacd
xh
bpxhv
f
pxh
hva
hvac
xhva
os
s
dy
qo
v
q
a
bpxhvacdy
xhv
qosu
yb
acdy
u
pxhvacd
c
vacdy
o
uf
xhvacd
vac
bpx
acd
bp
hvacdy
suf
bpxhvac
cd
h
pxhva
hv
pxhv
osu
d
y
xhvac
pxhvacdy
NO
20
ckdza
w
tvylck
bqtv
tvylckd
os
bqtvy
rpx
zaj
rpxebqtvylckdzajfmi
bqtvylckdzajf
vylc
tvyl
pxebq
f
pxebqtv
lckdza
wnh
s
pxe
osrpxebqtvylckdzajfmiwnh
25
za
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
bcdefghijklmnoprstuvwxyza
25
zdcba
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
efghijklmnoprstuvwxyzdcba
13
za
yb
xc
wd
ve
uf
tg
sh
ri
qj
pk
ol
nm
nmolpkqjrishtgufvewdxcybza
13
az
by
cx
dw
ev
fu
gt
hs
ir
jq
kp
lo
mn
azbycxdwevfugthsirjqkplomn
4
ab
bc
ca
d
NO
3
b
d
c
bcd
3
ab
ba
c
NO
2
ba
ca
NO
4
az
zy
cx
xd
azycxd
2
ab
bb
NO
2
ab
ac
NO
3
ab
ba
cd
NO
2
abc
cb
NO
1
lol
NO
2
aa
b
NO
6
a
b
c
de
ef
fd
NO
3
abc
cb
dd
NO
3
abcd
efg
cdefg
abcdefg
n = int(input())
a = []
al = set()
for _ in range(n):
  inp = input()
  a.append(inp)
  for c in inp:
    al.add(c)

al = list(al)

i = 1
while i < len(a):
  j = 0
  while j < i:
    if a[i] in a[j]:
      del a[i]
      i -= 1
    elif a[j] in a[i]:
      del a[j]
      i -= 1
      j -= 1
    j += 1
  i += 1

for i in a:
  for j in al:
    if i.count(j) > 1:
      print('NO')
      exit()

a.sort()
print(a[0], end = '')
last = a[0]
for i in a[1:]:
  if len(last) > len(i):
    j = len(last) - len(i)
    tj = len(i) + 1
    t = len(i)
    while j < tj:
      if last[j:] == i[:t]:
        i = i[:t]
      j += 1
      t -= 1
  else:
    j = 0
    tj = len(last)
    while j < tj:
      if last[j:] == i[:tj - j]:
        i = i[tj - j:]
      j += 1
  print(i, end = '')
