Special Cake
Time limit1sMemory limit1024 MB
Given N students' statements about who ate the cake, print every student who could be the culprit without contradicting any statement, or print swi if none can be.
- Level
Easy2 of 10
- Topics
- Brute force, Implementation
- Solved
- No attempts yet
Problem
Huuu...
Someone took advantage of the darkness and ate Swi's enormous cake again!
As usual, Swi, who loves cake, had set an enormous cake from a nearby shop on the dining table and was admiring it. The dormitory heater was so warm that Swi fell asleep, and the cake disappeared while Swi slept.
The thief is either Swi or one of the people other than Swi who were in the dormitory at the time. To find the culprit, Swi questioned all students who were in the dormitory during the night. Swi sorted each student's statement into one of two types:
- One of the students in list is the culprit.
- None of the students in list is the culprit.
If one of the students is the culprit, every other student knows who it is, so every student except the culprit tells the truth, and the culprit lies to hide the fact. If none of the students is the culprit, then Swi ate the cake, and the truth of the statements cannot be determined.
Swi uses the statements to narrow down the suspects. If assuming a student is the culprit creates no contradiction with the statements, that student is a possible culprit. If none of the students is a possible culprit, Swi is the culprit by elimination, so print swi.
Input
The first line contains the message that Swi's cake is missing (swi's cake is missing!).
The second line contains , the number of students other than Swi who were in the dormitory.
Each of the statements is given on three lines, and the student who made the -th statement has number . Each statement has the following format.
- The first line contains , the number of students in list .
- The second line contains the numbers of the students in list , separated by spaces, with no duplicates.
- The third line contains an integer that gives the type of statement. if the statement says the culprit is in the list, and if it says the culprit is not in the list.
Output
Print the numbers of all possible culprits in increasing order, separated by spaces.
If no student is a possible culprit, print swi.