TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

The 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.

Input Format

The 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.

Output Format

For 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.

Sample Input 1

2
aba
bab
ababababac
6
beta
alpha
haha
delta
dede
tata
dedeltalphahahahototatalpha
0

Sample Output 1

4
aba
2
alpha
haha

Hints

Problem Source

Migrated from old NTUJ.

2009Hefei

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 65536 200