Hibina

3.3

3 votes
Mathematics, Set, Easy, Mathamatics
Problem

Kamil and his friends are playing new board game Hibina. There are six types of playing cards in the game: yellow, green, blue, white, red and a wildcard. Each player has five cards, numbered 1 through 5, but the problem is that each player can't see his own cards. The only thing can be done is giving hints to other players.

Wildcard cards are very important in this game, so Kamil wants to know, which of his cards are wildcard, and which of them are not. It's difficult to distinguish wildcard cards from the ordinary ones, because wildcards are of each of other five colors, too.

The rule of doing a hint by player A to player B follows: a player chooses one of five colors, say x, such that B has at least one card of color x, including wildcards. This means that if player B has wildcard, A can choose any color. Then A points to all cards having color x. This will give an information to player B, that the cards, which A pointed to, are of color x, and others are not of color x.

You are given n hints made to Kamil. Help him detecting which of his cards are definitely wildcard and which of them are definitely ordinary.

Input format

First line contains single integer n — number of hints made to Kamil (0n20). Next n lines describe hints. Each of these lines starts with an integer k and a string x — the number of pointed cards during this hint and an English color name in lowercase Latin characters. Then k distinct numbers follow a1,a2,ak — which cards were pointed during this hint (1ai5; aiaj for ij).

Color names are yellow, green, blue, white and red.

It is guaranteed that there exists a hand of cards, so that all hints are correct.

Output format

Print exactly 5 lines, per line for each card: line i should contain YES if card i is definitely wildcard, NO if it's definitely ordinary and UNDEFINED if card i can still be as wildcard as ordinary.

Sample Input
3
4 red 1 3 4 5
3 green 4 1 2
2 blue 1 4
Sample Output
YES
NO
NO
YES
NO
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The following cards are possible in Kamil's hand: wildcard, green, red, wildcard, red.

Another testcase:

2

2 yellow 1 5

2 yellow 1 5

Answer is:

UNDEFINED

NO

NO

NO

UNDEFINED

Editor Image

?