#P1248. Special Week With Passwords
Special Week With Passwords
题目描述
Password, password and also the password! In this Internet world, one can not live without a password. We can use our account to pay something or chat with others or something else.
Also, Special Week has some passwords, but unfortunately, she has forgotten some of them.
In order to remember the passwords, she also has some principles in the password generation like most people, who always use their birthday as the password, which is about the prefixes.
A prefix of one string is like for example:
is the prefix, also is the prefix, is also the prefix, and is also the prefix.
bust is not the prefix as the prefix need to be consecutive.
So, this time Special Week just has reminded some of her passwords but has also forgotten some of her passwords.
The algorithm of her password generation is below:
- Generate some random strings like .
- Concatenate the prefixes of all the random strings with random length and the original order. For example, we can get just Concatenate the prefix of and with the prefix and . Please notice that we can't get because we need to concatenate them with the original order.
- Every string must contribute its prefix.
Now Special Week has remembered some of her passwords, but she doesn't know whether it is right. Please help her check them.
输入格式
The first line contains one positive integer indicating the number of the random strings.
Then followed lines, each line contains one string of length at most .
Then followed one positive integer indicating the number of the queries.
Then followed lines, each line contains one password of length at most 25 which might be right.
All strings only consist of lowercase English letters.
输出格式
For each query, if the password is right Then print YES, otherwise print NO
样例
3
abc
ab
abaad
4
aaa
aaad
ababa
aabab
YES
NO
YES
YES