Time Limit: 3000ms
Memory Limit: 65536kb
DescriptionThe archaeologists are going to decipher a very mysterious “language”. Now, they know many language patterns; each pattern can be treated as a string on English letters (only lower case). As a sub string, these patterns may appear more than one times in a large text string (also only lower case English letters).
What matters most is that which patterns are the dominating patterns. Dominating pattern is the pattern whose appearing times is not less than other patterns.
It is your job to find the dominating pattern(s) and their appearing times.
InputThe entire input contains multi cases. The first line of each case is an integer, which is the number of patterns N, 1<=N<=150. Each of the following N lines contains one pattern, whose length is in range [1, 70]. The rest of the case is one line contains a large string as the text to lookup, whose length is up to 106. At the end of the input file, number ‘0’ indicates the end of input file.
OutputFor each of the input cases, output the appearing times of the dominating pattern(s). If there are more than one dominating pattern, output them in separate lines; and keep their input order to the output.
2 aba bab ababababac 6 beta alpha haha delta dede tata dedeltalphahahahototatalpha 0
4 aba 2 alpha haha