F**king string!

Time Limit : 1 Second

Memory Limit : 128 MB

Submission: 237

Solved: 55

Description


xiaoY is a cute boy, he is addicted in the English words. Today he invents a game called "Finding the best common K”. Here is the way how the game works:



First, xiaoY lists N words he wants to play with:



canadian



canceled



so-nice (the phrase, We ensure that the words in the phrase will be connected by a '-')



Then, xiaoY gives a misspell word. Your task is to minimize K such that every word’s first K letters have at least a D-consecutive common part with the misspell word. (D-consecutive common part means a consecutive common part whose length is D).



Just like the case:



Misspell word:  canice D=3



As you see,       Common ("canadi", canice) = "can" >=3;   //first 6 letter of canadian!



  Common ("cancel", canice) = "can" >=3;



  Common ("so-nic", canice) ="nic">=3;



So the minimum K that satisfies this case is 6!



If you can't find K that satisfies the rules, then just output "-1"!


Input


Mutiple cases.



N (0<N<=10)  D (0<D<=100 )



N words followed (0<each word's length<=100)



Misspell word (0<length<=100)



0 0 indicates the end.


Output


The minimum K or -1


sample input
3 3
canadian
canceled
so-nice
canice
0 0
sample output
6
hint
source
He Jian, HUST Campus 2010, Preliminary
© 2015 HUST ACMICPC TEAM. All Right Reserved.