#P7001. Parking Fee Fraud Detection

    ID: 20208 Type: Default 1000ms 256MiB

Parking Fee Fraud Detection

Parking Fee Fraud Detection

The number of cars in Default City traveling to the city center exceeds the available parking spots. To combat overspill parking, the city introduced parking fees enforced by automated license plate scanners. However, some vehicle owners fraudulently occlude one or more characters on their license plates, resulting in partial recognition.

Your task is to help the Fraud Busters Initiative (FBI) by matching a partially recognized license plate with a list of potential complete registration codes. The recognized code may contain the character '?' in place of any digit or letter that is unrecognized. A candidate registration code is a match if it is the same length as the recognized code and if every character in the recognized code is either '?' or exactly matches the corresponding character in the candidate code.

Note: All inputs will be uppercase and digits.

inputFormat

The input begins with a line containing the recognized license plate code (a string consisting of uppercase letters, digits, and '?' characters).

The next line contains an integer n, representing the number of candidate registration codes.

The following n lines each contain a candidate registration code (each string is guaranteed to be of the same length as the recognized code).

outputFormat

Output all candidate registration codes that match the recognized pattern, in the same order as they appear in the input. Each valid code should be printed on its own line.

sample

A?C
3
ABC
ACC
ADC
ABC

ACC ADC

</p>