Hibina
Tag(s):

## Easy, Math

Problem
Editorial
Analytics

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 ($0 \le n \le 20$). 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 $a_1, a_2, \ldots a_k$ — which cards were pointed during this hint ($1 \le a_i \le 5$; $a_i \ne a_j$ for $i \ne j$).

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
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

UNDEFINED

NO

NO

NO

UNDEFINED

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

November Easy '16

OTHER PROBLEMS OF THIS CHALLENGE
• Math > Basic Math
• Math > Combinatorics
• Algorithms > Graphs
• Algorithms > Dynamic Programming
• Math > Number Theory