Time limit
2s
Memory limit
128 MB
At spring camp, the students solve problems during the day and discuss them at night. Each student's study style is one of the following four types.
kwon: always tells the truth, both during the day and at night.kim: tells the truth during the day, but lies at night.lee: lies during the day, but tells the truth at night.han: always lies, both during the day and at night.The director does not know the students' styles or whether it is currently day or night. The director hears several statements from some students and wants to infer the current situation and the students' styles.
Assume that every student knows every other student's style exactly. Given the conversation, write a program that prints every fact that must be true in all possible situations. If it is day, the students are problem solving; if it is night, they are discussing.
The first line contains the number of test cases T, where 1 ≤ T ≤ 10.
For each test case, the first line contains the number of statements N, where 1 ≤ N ≤ 100. The next N lines contain the conversation. Each line starts with the speaker's name followed by a colon. Student names are one of A through H.
Each statement has one of the following forms.
I am [not] ( kwon | kim | lee | han | lying ).X is [not] ( kwon | kim | lee | han | lying ).We are ( problem solving | discussing ).It is ( day | night ).[not] means that not may or may not appear. Inside parentheses, exactly one of the options separated by vertical bars appears. X is one of A through H.
For each test case, first print the case number in the form #1 through #10.
If the conversation cannot happen in any situation, print Impossible. If at least one situation is possible but no fact is forced by the conversation, print No idea. Otherwise, print every fact that must be true.
Facts can be printed in the following forms.
X is ( kwon | kim | lee | han).They are ( problem solving | discussing ).It is ( day | night ).Print student facts in order from A through H. After that, print the activity fact and then the time fact.