Suffix Tree - Dictionary Queries

hard
You are given a string S, and Q queries.
Each query consist of a string T.
You have to determine if T is a substring of S.

Input Format

Input consist of A string S and an integer Q followed by Q strings

Output Format

If T is a substring of S, print "y", else print "n"

Constraints

|S| <= 10^5
Q <= 1000
|T| <= 1000

Example

Input
2
abcdefghABCDEFGH
2
abc
abAB
xyz
1
xyz
Output
y
n
y
Previous
Suffix Tree - Application 3 - Longest Common Substring
Next
Aho Corasick - Application

Related Questions