Олимпиадный тренинг

Задача 38331. File mask


Задача

Темы: Символы
Misha is preparing for the exam in computer science. He is currently studying problem A4, which describes how to work with file masks:

For batch operations with files, file name masks are used. The mask is a sequence of letters, numbers, and other characters allowed in file names, which may also contain the following characters.

The symbol "?" (question mark) means exactly one arbitrary character.

The symbol "*" (asterisk) means any sequence of characters of arbitrary length, including "*" can also specify an empty sequence.

Since there is no open bank of tasks for the Unified State Exam in computer science, Misha has to train on his own. Write a program that will determine for each file name whether it matches the given mask so that Misha can check his answers. It is guaranteed that no more than one "*" character is present in the file mask.

Input
The first line contains the file mask. The next 5 lines contain the file names, one per line. File names consist of small Latin letters, numbers and the "." symbol. (dot), the mask can also contain the characters «?» and "*" (symbol "*" — no more than once). The length of each line does not exceed 20 characters.

Imprint
For each filename print the word "YES" if it satisfies the mask and "NO" otherwise. Words should be displayed in capital Latin letters without quotes, each in a new line.
Examples
# Input Output
1 ?or*.d??
fort.doc
ford.doc
lord2.doc
orsk.dat
port
YES
YES
YES
NO
NO