CF852G Bathroom terminal
Description
Smith wakes up at the side of a dirty, disused bathroom, his ankle chained to pipes. Next to him is tape-player with a hand-written message "Play Me". He finds a tape in his own back pocket. After putting the tape in the tape-player, he sees a key hanging from a ceiling, chained to some kind of a machine, which is connected to the terminal next to him. After pressing a Play button a rough voice starts playing from the tape:
"Listen up Smith. As you can see, you are in pretty tough situation and in order to escape, you have to solve a puzzle.
You are given $ N $ strings which represent words. Each word is of the maximum length $ L $ and consists of characters 'a'-'e'. You are also given $ M $ strings which represent patterns. Pattern is a string of length $
Input Format
The first line of input contains two integers $ N $ and $ M $ ( $ 1
Output Format
Output contains $ M $ lines and each line consists of one integer, representing the number of words that match the corresponding pattern.
Explanation/Hint
If we switch '?' with 'b', 'e' and with empty character, we get 'abc', 'aec' and 'ac' respectively.