eolymp
bolt
Try our new interface for solving problems
Problems

Letter Cookies

Letter Cookies

\includegraphics{https://static.e-olymp.com/content/72/72045e4b156356bd5966be246d0ac23183b260e0.jpg} Saetre has finally decided to put their famous Letter Cookies back on market again. Of course they are just as interesting to play with as to eat. Your little sister is trying to make words out of the letters she found in the box, but you want to be faster than her to decide whether it is possible to make the word or not. Given the letters in the cookie box, is it possible to spell out the words your little sister know show to spell? (After creating a word, she scrambles the cookies again and can reuse the letters for later words.) \InputFile The first line of the input consists of a single number \textbf{T}, the number of letter cookie boxes your sister has. Each test case starts with a line describing all the letters in this box, in no particular order. Then follows a line with \textbf{W}, the number of words she would like to spell, and then follow the \textbf{W} words to write on a single line each. \begin{itemize} \item \textbf{0} < \textbf{T} ≤ \textbf{100} \item \textbf{0} < \textbf{W} ≤ \textbf{100} \item All letters are uppercase letters from the english alphabet (\textbf{A}-\textbf{Z}). \item There are at most \textbf{1000} letters in each cookie box. \item Each word has at most \textbf{100} letters (but is not necessarily an actual English word). \end{itemize} \OutputFile For each word, output a line containing \textbf{YES} if it is possible to spell the word, or \textbf{NO} if it is not possible.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
ABANANACOOKIE
4
BANANA
LETTER
COOKIES
CAN
Output example #1
YES
NO
NO
YES