ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1350. Canteen

Time limit: 1.0 second
Memory limit: 64 MB
It’s dangerous to eat in a canteen — you may be poisoned by a not fresh food. One may fall into a coma because of the canteen’s chicken and the other feels OK. And vice versa. The food is cooked from M different food stuffs. There are N different food stuffs in the menu but not all of them are at the distribution. Assume that K + 1 students eat the food and we know for each student what products may poison him. The first student eats and he is not poisoned. How the dinner affect on the other students?

Input

The first line contains an integer N (1 ≤ N ≤ 100). The next N lines contain the food stuffs names — non-empty sequences of Latin letters and digits with length not more than 40 symbols. Then there is a number K (1 ≤ K ≤ 100) and K + 1 blocks describing the menu food stuffs dangerous for the canteen visitors afterwards. The ith block starts with a line with an integer Ni — an amount of dangerous food stuffs and then there are Ni lines with the names of those dangerous stuffs (0 ≤ Ni ≤ N). The first block describes the food stuffs dangerous for the first student, the next K blocks — for the rest ones. The input ends with the line containing an integer M (0 ≤ M ≤ N).

Output

K lines — the ith line should contain:
  • YES, if the dinner is harmless for the (i + 1)st student,
  • NO, if among the food stuffs there is a dangerous one for the (i + 1)st student,
  • MAYBE, if there may be different situations under the given conditions.

Sample

inputoutput
7
Rafinad
Kefir
Pastila
Smetana
Chokolade
Kljukva
Imbir
3
3
Rafinad
Kefir
Imbir
1
Rafinad
3
Kefir
Kljukva
Smetana
2
Imbir
Smetana
3
YES
NO
MAYBE
Problem Author: Pavel Egorov
Problem Source: USU Junior Championship March'2005