문제
Guess Who is a two-player board game in which a number of characters are uniquely identified by a set of attributes (e.g. wearing glasses), and each player attempts to guess the other player's hidden character by asking a number of yes/no questions such as "does the person wear glasses?"
In our variation of this game, there are characters, each of which is uniquely identified by a set of attributes. The value of each attribute is either YES or NO. You will be provided with a list of the characters and their attributes, together with a series of questions and the corresponding responses. Your task is to determine the hidden character, if possible.
입력
Input begins with three space-separated integers , , and , satisfying , , and . The next lines each contains a string of characters that are either Y or N. The th line specifies the values of the attributes of the th character. Each of the next lines contains an integer , followed by a space, followed by a single character Y or N. This indicates the question is about attribute , and the response that the attribute of the hidden character is YES or NO. There is at most one question for each of the attribute. At least one of the listed characters has attributes consistent with the responses of the queries.
출력
In the first line, output one of unique or ambiguous, indicating if there is a uniquely identifiable hidden character, or if there are multiple possible hidden characters.
In the case in which the hidden character is uniquely identifiable, output on the second line the index (between 1 and ) of the hidden character. If there are multiple possible hidden characters, output on the second line the number of possible hidden characters.
예제 입력 1 복사
5 5 3
YYYYY
NNNNN
YNYNY
YYYNN
NNYYY
1 N
2 N
3 Y
예제 입력 2 복사
5 5 3
YYYYY
NNNNN
YNYNY
YYNNN
NNNYY
1 Y
5 Y
3 Y
예제 출력 1 복사
unique
5
예제 출력 2 복사
ambiguous
2