Loading...
Mr. Toto and Integers
Time: 1 s
Memory: 256 MB
Mr. Toto the mysterious character went out for a morning walk in the road. There he found a piece of paper containing a mathemathical puzzle. Also there was a notes writting behind the paper that if anyone can solve the puzzle, can win a lots of money.

Who dont like having so much money? As expected Mr. Toto wants to solve the puzzle and win money. But as we know that Mr. Toto is good in geometry and not good at any other things, he wants you to help him win the money.

In the puzzle, There is an integer N written on it followed by Q questions. In each question there was a integer number X written in it. The task is to determine if it is possible to retrieve X from N deleting some digits (possibly zero) of N from the start, end or middle. Can you solve the puzzle for Mr. Toto? Ovbiously you will be rewarded by Mr. Toto if he wons the money.   
Input
The First Line of Input Contains an Interger (0 <= N <= \(10^{500000}\))
The next line contains an integer Q ( 1<= Q <= 1000)
Each of the next lines contains an integer (0<= X <= \(10^{1000}\))
Output
For Each questions print "YES" if  can be retrieved from N, print "NO" otherwise.
Examples
Input
Output
1234567891234
5
1499
23234
1424
91234
912345
NO
YES
YES
YES
NO
Notes
In the First case it is not possible to retrieve 1499 from 1234567891234.
in the second case 23234 can be retrieved from 1234567891234 by deleting bold digits.
in the third case 1424 can be retrieved from 1234567891234 by deleting bold digits.
Problem Info
Problem ID 224
Time Limit 1000 ms
Memory Limit 262144 KB
Moderators Alom_Shanto , mfctanzim , raj3100 , abujafar492
Statistics
Submit
You need to Login or Registration for submit your solution