Nila was gifted a bracelet G made of lower case English Alphabets on her birthday. She ordered Q more bracelets each not longer than the gifted bracelet.
She reversed one of the ordered bracelet and placed it below G such that the last alphabet of it and the last alphabet of G coincide, as shown below(example). Let the bracelet picked be H = “hgfedc”.
Bracelet G : ab|cdefgh
Reversed H : cdefgh
She then cut (|) G at the point as shown and obtained G = ab. She then concatenated H to G at the point of cut and obtained G = abcdefgh. Here we see that the bracelet before cutting it was obtained again. [The entire string can be cut too]
Nila tried doing this with each of the Q bracelets. (She repairs G to the state before cutting after performing each operation)
Determine if the bracelet before cutting was obtained again for all Q bracelets.
Input Description:
The first line contains a string denoting bracelet G The next line contains an integer Q The next Q lines contain a string each, denoting a bracelet.
Output Description:
Print Q lines each containing YES if the bracelet was restored, NO otherwise.
Sample Input :
abcd
2
dc
b
Sample Output :
YES
NO