eolymp
bolt
Try our new interface for solving problems
Problems

Search by template

Search by template

The pattern \textbf{P} and the text \textbf{T} are given. They contain the letters of the Latin alphabet (lowercase and uppercase). The pattern may also contain the characters '?', '\[', '\]', '\{' and '\}'. You must find all the positions where \textbf{P} appears in \textbf{T}. Each position in the pattern \textbf{P} may contain: \begin{itemize} \item a letter from the Latin alphabet ('\textbf{a}' - '\textbf{z}', '\textbf{A}' - '\textbf{Z}') \item the character '\textbf{?}' that can replace any letter (on its place can be any letter) \item brackets '\textbf{\['...'\]'}, between them there is the set of letters that may be in the current position \item brackets \textbf{'\{'...'\}'}, between them there is the set of letters that are not allowed to be in the current position \item the letters can be repeated in brackets like \[\textbf{asssa}\] or \{\textbf{kLLf}\} \end{itemize} For example, if the pattern \textbf{P} is \textbf{A?\[bcC\]\{De\}}, then the first letter of a match must be '\textbf{A}', the second can be any Latin letter, the third - letter \textbf{b}, \textbf{c} or \textbf{C}, and the fourth can be any Latin letter except \textbf{D} or \textbf{e}. \InputFile The first line contains the number of test cases \textbf{n}. Each test consists of two lines. The first line contains the pattern \textbf{P} with no more than \textbf{100} characters and \textbf{60} positions. The second line contains the text with no more than \textbf{10^6} letters. \OutputFile For each test case print in a separate line all text positions, where the pattern matches, in ascending order (the first letter of the text \textbf{T} is assumed to have the position '\textbf{1}'). If the pattern \textbf{P} does not appear in text \textbf{T}, print the message "\textbf{no match}".There must be a single space between each printed position, and no extra space at the beginning/end of line.
Time limit 2.5 seconds
Memory limit 256 MiB
Input example #1
3
A?[bcC]{De}
yAqCpsApbeAocqq
???[QWERTY]
aSdFrQererRTY
{eRT}?
eRTeRTq
Output example #1
2 11
3 8 9 10
no match
Source SEERC-2011