#Lutece1852. Regular Expression
Regular Expression
Migrated from Lutece 1852 Regular Expression
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
A regular expression, regex or regexp (sometimes called a rational expression) is, in theoretical computer science and formal language theory, a sequence of characters that define a search pattern. Usually this pattern is then used by string searching algorithms for "find" or "find and replace" operations on strings.
"?
" : The question mark indicates zero or one occurrences of the preceding element. For example, matches both "color" and "colour".
Given a string consist of lower-case English letters only and some string , your task is to count the numbers of substring of the which matches .
Input
The first line of the input contains a string ()
The next line contains number of query ().
Each question contains a string ().
It's guaranteed that no two question marks appear continuously and no question mark appears at the beginning.
Output
For each query print the corresponding answer in a single line.
Samples
abcaaaa
3
a?a
a?b
c?a?
8
2
7
Resources
The 16th UESTC Programming Contest Preliminary