Problem8629--ALDS1_14_D : String Search

8629: ALDS1_14_D : String Search

[Creator : ]
Time Limit : 5.000 sec  Memory Limit : 256 MiB

Description

Determine whether a text T includes a pattern P. 
Your program should answer for given queries consisting of $P_i$.

Input

In the first line, a text T is given. 
In the second line, an integer Q denoting the number of queries is given. 
In the following Q lines, the patterns $P_i$ are given respectively.

Output

For each question, print 1 if the text includes $P_i$, or print 0 otherwise.

Constraints

1 ≤ length of T ≤ 1000000
1 ≤ length of $P_i$ ≤ 1000
1 ≤ Q ≤ 10000
The input consists of alphabetical characters and digits

Sample 1 Input

aabaaa
4
aa
ba
bb
xyz

Sample 1 Output

1
1
0
0

HINT

相同题目:ALDS1_14_D

Source/Category