In Computer Science, pattern matching is the process of checking whether a given sequence matches a specified pattern. Patterns are often specified using a language based on regular expressions. In this problem, we use a simple regular expression to represent patterns in sequences of decimal digits. A pattern is a sequence made up of one or more decimal digits , asterisks , and hash signs . A denotes a sequence of an even number of digits, while a represents a sequence of an odd number of digits.
For example, the pattern matches only the sequence . The pattern matches all sequences starting with , ending with , and having an even number of decimal digits between the first and last digits. Another example: the pattern matches the sequences , , , but not the sequences , , .
Your task is to write a program that determines whether a given sequence matches a given pattern.
Your program will be tested on one or more datasets. Each dataset contains a single pattern and one or more sequences to match. The first line of each dataset specifies the pattern, and the remaining lines specify the sequences to match against that pattern. The end of a dataset (except the last) is indicated by the word (without quotes). The end of the last dataset is indicated by the word . All lines are at most characters long.
Here, is the number of the test case (starting at one), is the number of the sequence (starting at one within each test case), and is either the word if the given string matches the pattern, or the word if it does not.
Example 1