eolymp
bolt
Try our new interface for solving problems
Problems

Find a set of patterns 2

Find a set of patterns 2

For each string from the given set \textbf{S }check, is it true that it contains as a substring at least one string from the set \textbf{T}. \InputFile The first line contains the number of strings \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{1000}) in the set \textbf{T}. Each of the next \textbf{n} lines contains the nonempty string. It is guaranteed that the total sum of all the strings from a set \textbf{T} does not exceed \textbf{80000}. The last part of the input contains the satrings from the set \textbf{S}. Each line consists of ACII characters with codes from \textbf{32} to \textbf{126} inclusive. The string can be empty. The total input does not exceed \textbf{1} МByte. \OutputFile Print all the strings from set \textbf{S} (in the same order as they are in input), that contains as a substring at least one string from set \textbf{T}.
Time limit 1 second
Memory limit 445.47 MiB
Input example #1
3
gr
sud
abc
lksh
sudislavl
kostroma
summer
group b
Output example #1
sudislavl
group b