Letter Cookies

No attempts yetTime limit1sMemory limit256 MB

Problem

A cookie maker has put its letter cookies back on sale. They are as much fun to play with as to eat. Your little sister is making words out of the letters she finds in the box, and you want to decide before she does whether a word can be made.

Given the letters in a cookie box, decide for each word your sister knows how to spell whether she can spell it. After she finishes a word she scrambles the cookies back into the box, so the same cookies are available again for the words that follow.

Input

The first line contains TT, the number of letter cookie boxes your sister has. Each box starts with a line listing all the letters in that box, in no particular order. Then comes a line with WW, the number of words she would like to spell, followed by the WW words, one per line.

  • 0<T1000 < T \le 100
  • 0<W1000 < W \le 100
  • Every letter is an uppercase English letter from A to Z.
  • A box holds at most 1000 letters.
  • Each word has at most 100 letters and is not necessarily an actual English word.

Output

For each word, print one line containing YES if the word can be spelled, or NO if it cannot.