As we communicate, we learn much new information. However, the process of communication takes too much time. It becomes clear if we look at the words we use in our everyday speech.

We can list many simple words consisting of many letters: "information", "technologies", "university", "construction", "conservatoire", "refrigerator", "stopwatch", "windowsill", "electricity", "government" and so on. Of course, we can continue listing those words ad infinitum. 

Fortunately, the solution for that problem has been found. To make our speech clear and brief, we should replace the initial words with those that resemble them but are much shorter. This idea hasn't been brought into life yet, that's why you are chosen to improve the situation. 

Let's consider the following formal model of transforming words: we shall assume that one can use *n* words in a chat. For each words we shall introduce a notion of its shorter variant. We shall define shorter variant of an arbitrary word *s* as such word *t*, that meets the following conditions:
 -  it occurs in *s* as a subsequence, -  its length ranges from one to four characters. 
In other words, the word *t* consists at least of one and at most of four characters that occur in the same order in the word *s*. Note that those characters do not necessarily follow in *s* immediately one after another. You are allowed not to shorten the initial word if its length does not exceed four characters.

You are given a list of *n* different words. Your task is to find a set of their shortened variants. The shortened variants of all words from the list should be different.
The first line of the input file contains the only integer *n* (1 ≤ *n* ≤ 200). Then *n* lines contain a set of different non-empty words that consist of lowercase Latin letters. The length of each word does not exceed 10 characters.
6
privet
spasibo
codeforces
java
marmelad
normalno
pr
p
e
v
re
r
5
aaa
aa
a
aaaa
aaaaa
-1
26
aaaaa
aaaab
aaaac
aaaad
aaaae
aaaaf
aaaag
aaaah
aaaai
aaaaj
aaaak
aaaal
aaaam
aaaan
aaaao
aaaap
aaaaq
aaaar
aaaas
aaaat
aaaau
aaaav
aaaaw
aaaax
aaaay
aaaaz
aaaa
aaab
aaac
aaad
aaae
aaaf
aaag
aaah
aaai
aaaj
aaak
aaal
aaam
aaan
aaao
aaap
aaaq
aaar
aaas
aaat
aaau
aaav
aaaw
aaa
aa
a
26
aaaa
aaab
aaac
aaad
aaae
aaaf
aaag
aaah
aaai
aaaj
aaak
aaal
aaam
aaan
aaao
aaap
aaaq
aaar
aaas
aaat
aaau
aaav
aaaw
aaax
aaay
aaaz
aaaa
aaab
aaac
aaad
aaae
aaaf
aaag
aaah
aaai
aaaj
aaak
aaal
aaam
aaan
aaao
aaap
aaaq
aaar
aaas
aaat
aaau
aaav
aaaw
aaa
aa
a
6
xxxxx
yy
xxxx
xxxxxx
xxxxxxx
y
xxxx
yy
xxx
xx
x
y
9
abacaba
aba
abac
a
ab
ddddd
dddd
dd
d
abac
aa
aba
a
ab
dddd
ddd
dd
d
13
a
aa
aaa
aaaa
c
cc
ccc
cccc
z
zz
zzz
zzzz
u
a
aa
aaa
aaaa
c
cc
ccc
cccc
z
zz
zzz
zzzz
u
9
rrr
r
rr
rrrr
arrrr
a
arr
ar
arrr
-1
1
dfjasasdat
d
3
acaca
caca
a
aca
ac
a
10
bftyrwwarr
zcewcuhj
u
skfyovxj
tdffmpaify
m
gy
ctkwdncog
vne
bdbov
bf
w
u
fy
f
m
y
t
e
b
20
aaaaba
baaba
baaabb
babbab
babbaab
bbaaab
bbaabab
aaaabbb
aaaabba
baaaaa
abbaba
ababb
baabb
aababb
abbaaa
baaaba
aaababb
bbababa
abbba
babaaab
aab
bab
bbb
baa
bb
bba
baba
ab
aaba
baaa
ba
babb
baab
b
aba
aaab
aaaa
aaa
aa
a
7
abbaa
bbbba
babbb
baaba
aabbb
ababb
abbba
abba
bb
b
aba
abb
ab
a
38
dadi
fiag
h
idb
dih
g
ej
cjj
d
icfe
bbi
dc
cgj
dgfag
fg
fjed
icffg
f
jfab
ehba
cea
djc
fh
eh
gcji
ig
hccjj
bh
i
bfd
dhfe
hcjf
cf
iegca
e
ead
c
ebbc
dad
fi
h
id
di
g
ej
cjj
d
icf
bb
dc
cg
da
fg
fe
ic
f
fa
a
ce
dj
fh
eh
gj
ig
j
bh
i
fd
dh
cj
cf
ia
e
ad
c
b
27
bbbab
aaaba
aaabb
abbba
abbab
aabbb
baabb
aaaaa
bbabb
babab
babaa
baaab
abaaa
abbbb
bbaba
ababb
abaab
baaaa
bbbbb
babbb
babba
aabaa
aabba
abbaa
bbbaa
ababa
bbbba
bba
aaba
aaab
ab
abb
aabb
aa
aaaa
bbab
bab
bbaa
baa
aba
abbb
baba
aab
abab
baaa
bbbb
babb
bbba
aaa
a
ba
bbb
bb
b
69
dni
phocegch
l
gdh
angim
qk
hnqim
docbhe
dgi
lgediqld
cm
gnnkl
hcqbd
ombb
iqnfj
ic
opkcn
fpoop
e
gbeda
qehqeb
blbmekdmgc
peg
ngalnic
mnmfoqi
qa
hql
mligibddg
fqhojaq
jmkmahj
qn
pgmck
ehkbbihhca
a
op
dnioihf
hbiggi
hkefkfef
kgeeoq
ck
qjmkoodan
ppn
dfqele
njbaif
npbgopibeh
bcbaq
geagehh
gd
fnobnbfge
n
ebkec
cfehnb
olel
mfbie
bkf
ke
gdgdcnlk
ebgfm
qhmd
fqmeodg
joo
j
hikmj
bnmellmlpm
dcekgmenq
bjohhkkdjn
bibjlekjgh
kcjlannfaj
lql
dni
ph
l
gh
ang
qk
nim
he
dg
i
cm
gl
d
ob
iq
ic
pc
po
e
be
eh
c
pe
gc
ni
qa
hq
gi
ho
m
qn
pg
hc
a
op
di
hg
f
g
ck
o
pn
de
ai
p
cb
eg
gd
oe
n
ec
ce
le
mb
b
ke
k
gm
hm
og
oo
j
im
nm
dn
hh
h
an
q
30
abbbbbbb
bbbbcaca
caabcbac
bbccacbb
bcabcbcb
bcccabac
accabcbb
babaaabc
ccabbccc
cbccbacb
bacccaab
aacacccc
bccbcaab
ccabccac
cbbbacab
bbabbcab
bcbbbccc
abbcbaba
ccbbbaac
cbcabaaa
cbbcccab
cbababbc
ccccacaa
abcbcbcb
ccccacbc
ccccaaba
bcaabaaa
cbabcccc
aabccbbb
aabcbcca
bbbb
bbba
bc
bbca
bcc
baa
bbb
abb
cac
bcca
bac
cc
bbc
bcac
bbaa
bbbc
bbcc
bcaa
ba
bba
bca
bbac
caca
abbb
ca
c
bb
b
ab
a
14
cd
ea
g
bea
e
gcd
a
ec
efe
aa
d
b
cgb
bb
cd
ea
g
be
e
gc
a
ec
ef
aa
d
b
c
bb
31
aaabb
bbaab
aabab
bbaaa
bbbab
babaa
baaab
bbaba
babbb
baaaa
babab
aaaaa
aaaba
abaaa
abaab
abbbb
aabba
aabaa
abbaa
aabbb
abbba
bbbbb
baabb
aaaab
babba
ababb
bbbaa
abbab
bbbba
bbabb
ababa
-1
92
a
b
ba
cacab
ab
cba
ee
aeec
ceb
e
dd
ccbba
bd
daeda
ac
dbeb
beb
aecac
ddbea
bca
cbcec
ad
d
ccad
acc
dda
baccd
de
ccabb
eba
eacc
da
dbeab
ea
bbbb
be
dcc
daebb
adc
cd
dcde
ebdd
bea
abeb
dbb
abaaa
aa
aec
edea
daaa
daee
dae
ddd
bde
dccaa
dee
eddce
aaee
cceac
eebe
eeedd
db
abac
ec
ecced
ccca
cabce
caac
cbed
baca
dc
ca
bdec
c
cbeba
dbc
bbb
bbc
bcce
dabad
adca
daaed
abe
ecc
ceaae
dba
bbd
aeecb
ebb
cacc
decdc
adeec
a
b
ba
caca
ab
cba
ee
aee
ceb
e
dd
ccb
bd
daea
ac
dbeb
beb
aca
dbe
bca
cb
ad
d
ccad
acc
dda
bcc
de
cab
eba
eacc
da
dea
ea
bbbb
be
dcc
eb
adc
cd
dcd
ebd
bea
abb
dbb
aba
aa
aec
ed
aaa
daee
dae
ddd
bde
daa
dee
dde
aae
eac
eeb
edd
db
aac
ec
cce
cca
cbc
cac
ce
bac
dc
ca
bec
c
cbb
dbc
bbb
bc
cc
dad
ada
daed
abe
ecc
caa
dba
bbd
acb
bb
ccc
ded
ae
38
ftilownp
m
lkkm
iasdn
ahscnifvs
e
okd
cagbyfrw
lxapbvus
cnx
qfger
lqgto
s
vff
f
y
i
pf
motybxx
oqxogymc
mngrwdgmp
r
ghhghgb
vbivsydebp
fxyy
nafptkoev
owpqwi
yu
kgm
idpif
j
flr
mfikogr
rs
efbj
qns
surq
raffxw
fti
m
lk
in
is
e
k
w
l
c
g
to
s
v
f
y
i
pf
t
o
wp
r
h
p
x
ft
ow
yu
km
ip
j
fl
fi
rs
b
n
u
fw
38
lqqdalhnnq
jgdldfcncd
cpillzoinz
zbtngejkgf
bonvoakzmw
khdvqzcmwy
kuvvoqmexl
aiagjntziy
nmcmvywhsb
rdcsfxjkoc
kvvwmwdckx
iqsswuaghz
vldpgiqrsn
vxidkiiftf
fdlgqhbazs
ssmgezzqkt
gikgmulnuu
lagukctxqa
lfqwjosyol
didicqelvk
tonbduvwme
emfgzgialb
zzgxgfrtej
yrxzloihor
jrywplurxi
silmgqbefh
bidzqhqpav
qylrfqbwve
drkkhlocmg
tjolhjhper
ebaapngqss
vtbdyagdas
cozmkpnezy
ugcawxtlaw
gqwvetfhcw
yhjdpqtfcy
wydilfrgzw
ejdswvtxlr
lqq
ld
ll
jg
n
dq
o
an
h
jc
dc
qa
lqn
df
lqa
z
ln
lq
lql
ql
nd
al
g
lh
jl
lqh
qqa
qq
dl
j
a
da
c
la
qh
q
d
l
39
aabaaababa
abbabbbabb
babbabbabb
aaabbabaaa
aabbaaaabb
abbabbaaab
abbbbabaaa
abbbbbbabb
bbabaaaaab
aabaabaaba
babaaababa
aaabababba
aaabaaabab
bbbaaaaabb
baaabaabab
bbabbbbaab
abaaabaaab
abbbbababa
abbabaabab
bbbabaabab
bbbbababaa
bbbbbababb
bbbbbbaaab
babbbbbbab
baaaaabbaa
aabaabbabb
bbaaabbbba
abbbabbaab
bbbabbaaab
abaabbabaa
abaaaaabab
bbbaabbaaa
bbbabbbaaa
aaababbaaa
bbbbbbbaaa
abbabbabaa
bbbabbbbba
bbaaaabbaa
aaaabbaaba
-1
39
babaaacbca
bbbaaabaca
bcabaccbbc
aacbbbabab
bcacaaabba
accbacacaa
cabababbca
bacaabbabb
abbbcacaab
aaacabcccc
ccabbaaacb
cabcbbcaab
cbcabcccba
abbbaabaaa
bcbbababcb
ccbabcaaca
bbcacacccc
bcbbbaacbb
abcaccbcba
bcbccabcac
baacbbabba
bcbbaacbba
cbbabbbbac
bacacbbbba
bacbaccbaa
bacccbccab
ccbaacccbc
baabcbcaca
caccacbaca
babcbcbaba
caabcbacaa
baccaaabbc
bbabbbcbba
bacbbcbcab
abcaaaacac
abcacacabb
aacaabcacb
bcabaabcca
bcbcaaabab
bbbc
bb
bcb
abab
baca
bcc
bbc
bca
bbba
a
bbac
bbca
bcbc
abaa
bbcb
bacc
bcca
bc
bcba
bbab
bacb
bbb
ab
baa
baaa
bbcc
abc
bba
aba
babc
bbaa
bac
baba
baab
baac
babb
bab
ba
b
39
aaaaccddcc
bacaaadaac
badcadccdc
bccaaadbdb
bdbacbbddc
bdabdbcdbd
ccaacdadaa
cdaaabbbcd
babdbbcddc
dcdadaaaad
bbaaadabcd
bdcddbbcaa
aabdaccadd
cccdbdbdbb
bdcccdcaaa
aaaaddddbb
aabbaabaaa
cabdbacbba
bbbaddabaa
acdcabacab
dacdacdaab
dacbbdbbdd
bcbbbaccdb
ccbabaaccb
bcbddadadd
dabddbabad
dcdcbaacda
acccabdaad
caddbbccac
dddcbbdbcc
acacdaabad
accccbbcbc
bdbbbabbad
bdadddcbbd
ccbcdcddac
baddabacdc
dcadbbbada
cabbacadac
ddcbacabda
accd
aaad
aacd
aad
acdc
ad
aadd
ccd
acd
dd
aadc
cdd
aaaa
ccdd
ccdc
addd
baa
adc
ba
adcc
aac
acdd
ccc
aacc
cd
b
ac
accc
add
cdc
acc
c
d
addc
cc
aaac
aaa
aa
a
50
bjiajhi
ihabfjbcj
facaeheaf
bjideb
iacacdfjg
gjbfhae
ghcefg
dfejf
jceaadh
hdjdedbbg
jjgagaff
cchdfc
afghf
begfib
ehgjjjga
igjjed
ghggjbi
bjfhiehc
edeedchfa
acdhacgdga
adbebijbb
ieida
fehhbdf
cgdfgjid
ahcbiidhaj
dhbdcic
hdhhhei
edbhfda
dhah
cbjcfb
bfggdbg
fbacccdfa
jfbibaji
fbaahi
jaee
hifefihcg
bajabbbf
gfddebcbeg
hgcchhfigi
edghgcg
ffijjh
bcbiej
beafgcebd
bhfj
gcdjgehdi
cgdjcebcb
egij
hgbd
fgbjcaegaf
cdabjebbbf
bjia
bjj
haf
bji
iaj
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
p
ah
gjj
gb
hf
bo
tu
qo
q
gg
mi
g
gd
t
vn
ri
di
cp
c
eu
fo
nd
s
rm
i
nr
ns
f
n
v
d
pp
tt
td
a
e
pg
u
m
b
6
y
s
x
b
z
v
y
s
x
b
z
v
29
cg
od
eg
df
ln
ar
oo
bh
qi
cs
ea
ng
eb
nl
dm
gm
nd
ff
pn
es
jf
bb
am
hj
gh
nm
sk
gd
iq
cg
od
e
df
ln
ar
o
bh
qi
c
ea
n
b
l
dm
gm
d
ff
p
s
f
bb
a
j
h
m
sk
g
q
40
gbai
degd
fieb
bfcg
ieci
icbg
eahe
cice
fefc
ciaf
eehe
eaca
ifdh
abhe
eiac
fiah
aiee
echc
giga
bdad
fhdc
ihdd
ibdf
feag
fddd
fhdd
ffbc
hbgb
gieg
dghh
fgfh
hdff
ceib
deef
bfha
fehi
egfg
acdd
ieff
bbed
gba
deg
i
bfc
iec
bg
eah
ie
fc
ci
eh
ea
if
ah
c
fi
ai
ec
ga
dd
d
h
bf
fe
fdd
fd
fb
gb
gi
dg
g
ff
ib
de
ba
f
eg
a
e
b
80
bbbb
abb
abbb
abbbb
bbaba
aaaba
aaaa
bab
bbba
bbaa
baa
baba
bbabb
aba
bbbab
aaba
aaa
bbb
bbbbb
aabaa
aabb
aabbb
abbaa
aab
bbab
bba
abaab
bbaaa
aaaaa
baaab
aaabb
baaa
aabab
abaa
ababb
babaa
ababa
abbba
abab
baab
zyyz
yyz
zyz
zzz
zzy
zyyzz
yzyz
zyy
yzz
zzyzz
zzyz
zzzzz
zzyy
yyyzy
yyy
yzyyy
zzyyy
zzzyz
zyyy
zzzzy
yzzyy
yzyy
zyyyy
zyzzy
zyzyy
yyzzy
yzyyz
yyyyz
yzzz
zyzz
yzzy
yyyz
yzy
yyyy
zzzyy
yyzyy
yzyzz
zzzz
zzzy
zyzy
-1
59
dadd
ddbb
cdcb
cdbcba
cddbcb
cdbc
acdd
ddc
dacad
bcadc
cccdd
bdab
acbc
bddca
dcb
bab
cbaa
bda
cdbda
caca
cada
cadddc
dadcb
aabb
ddccab
dabdcd
aaaabb
bacac
bddd
bbbc
acca
ddbadd
acbcb
dbbd
bacb
dcada
dbaddd
bddcd
dcad
dbca
abc
dddb
bba
aaadbd
cdbdd
bdabca
bdc
cddcac
cdbcaa
dab
bdd
dcdc
dcbb
bbd
acc
dbb
cdc
adaad
bbbd
dadd
db
ccb
cdcb
ddbb
cb
cdd
ddc
dad
cdc
ccc
bda
bc
ca
dcb
bab
cba
ba
cdba
aca
ad
ddd
ddcb
aab
ddb
add
ab
bca
bddd
bbb
cca
dd
cbc
dbd
bcb
cda
dba
dcd
dca
a
ac
dddb
bba
aa
cdb
dbc
dc
cdca
b
dab
bdd
cc
dbb
bd
c
bb
cd
da
d
54
bbaa
bcba
cda
bacd
cca
dc
dd
dbc
db
bcab
adac
cdc
bdc
cddb
cdda
aac
bcb
aaca
dcd
bcdb
ada
acc
da
ccdc
bab
bd
acd
ccdd
cbb
dcdd
dda
bbba
dab
dccc
ca
bccc
bb
acb
cacd
dad
ba
cb
aadb
ad
bc
ccaa
bdcb
ab
aa
bad
cd
cccd
ccba
bbc
bbaa
bba
cda
bc
cca
dc
dd
dbc
db
bca
adac
cdc
bdc
cdd
cdda
aac
bcb
aaca
dcd
bcd
ada
acc
da
ccdc
bab
bd
acd
ccd
cbb
dcdd
dda
bbb
dab
dcc
ca
ccc
bb
ac
cd
dad
a
cb
aad
ad
c
ccaa
bdb
ab
aa
bad
d
cc
ba
b
63
daac
ba
cacb
daabb
cdd
bbdaa
add
cba
bcda
dc
dabcc
bdaa
aa
ddbcb
cbad
cdcdd
bdc
dbad
caddb
aaadb
bdadc
bdd
adc
dd
aad
cd
yzzxy
zxyxy
xz
xyyzy
xxy
xzyyx
xzxzz
yzy
xyzzy
zxxzy
yy
zzz
xyz
yzxz
zxyx
yxxzz
yz
zyy
xx
zz
yxx
xxxz
xyyyy
yyxx
yxzz
yxyz
yxxxx
yyz
yyyy
zzzz
zzxzz
zxzz
xxzx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z
zzyz
yzxz
yyzz
zxzx
zxz
zz
xyyz
yxz
zxy
yxyy
zxxx
y
z
yxxz
zy
xz
xy
xx
x
14
aaabaaaaaa
a
b
aa
ab
ba
aaa
aab
aba
baa
aaaa
aaba
abaa
baaa
aaab
a
b
aa
ab
ba
aaa
aab
aba
baa
aaaa
aaba
abaa
baaa
15
aaabaaaaaa
a
b
aa
ab
ba
aaa
aab
aba
baa
aaaa
aaba
abaa
baaa
aaab
-1
26
bbaab
baaaaa
bbba
ab
ba
bbbbbb
bbaaaaa
baa
aaab
aa
bbababb
bba
abaa
baabab
abbaab
bbb
aaba
bab
bbbbb
aba
aaababa
bb
bbbab
ababba
aababab
aaaa
bbaa
baaa
bbba
ab
ba
bbbb
aaaa
baa
aaab
aa
babb
bba
abaa
aab
abab
bbb
aaba
bab
bb
aba
baba
b
bbab
aaa
baab
a
37
egcf
bfcfb
edbga
cbfa
ec
de
bbaf
ef
ecgcg
bdb
bdbfd
aad
cbee
fc
bdbce
fbaba
eg
gfgag
efedd
cgb
cdggd
ccb
gg
gedg
cdgc
fdg
bf
dgbgb
aeca
ffae
eb
ebeeg
eebee
bdd
ggff
cfbb
daed
egcf
b
edb
f
ec
de
ba
ef
egc
d
bb
a
c
fc
bc
fb
eg
ga
ed
cb
cg
cc
gg
edg
gc
dg
bf
g
ea
ff
eb
ebg
be
bd
gf
cf
e
20
fagd
fca
bcda
gaea
afd
fedfg
becc
aebg
bga
cfdeg
ccd
eaa
gabfd
beag
fbgda
fagcf
acbed
edabf
bdde
dbeb
fagd
fc
ca
ga
fd
g
bc
ag
ba
fg
cd
aa
ad
a
fa
fag
c
f
b
d
n=int(input())
a=[]
for i in range(n):
	a.append(input())
for i in range(n):
	if len(a[i])<4:
		print(-1)
	else: 
		print(a[i][0:4])
# Thu Jul 22 2021 14:03:58 GMT+0300 (Москва, стандартное время)
