Under construction

Still being built. Things may change

Special Cake

Time limit1sMemory limit1024 MB

Summary
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 NN people other than Swi who were in the dormitory at the time. To find the culprit, Swi questioned all NN 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 SS is the culprit.
  • None of the students in list SS is the culprit.

If one of the NN 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 NN students is the culprit, then Swi ate the cake, and the truth of the statements cannot be determined.

Swi uses the NN statements to narrow down the suspects. If assuming a student is the culprit creates no contradiction with the NN statements, that student is a possible culprit. If none of the NN 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 NN, the number of students other than Swi who were in the dormitory.

Each of the NN statements is given on three lines, and the student who made the ii-th statement has number ii. Each statement has the following format.

  • The first line contains MM, the number of students in list SS.
  • The second line contains the numbers S1,S2,⋯ ,SMS_1, S_2, \cdots, S_M of the students in list SS, separated by spaces, with no duplicates.
  • The third line contains an integer BB that gives the type of statement. B=1B=1 if the statement says the culprit is in the list, and B=0B=0 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.

Constraints

  • 1≤N≤101 \le N \le 10
  • 1≤M≤N1 \le M \le N
  • 1≤Si≤N1 \le S_i \le N

Examples3

  1. Example 1

    Input
    swi's cake is missing!
    2
    2
    1 2
    1
    2
    1 2
    1
    
    Expected output
    swi
    
  2. Example 2

    Input
    swi's cake is missing!
    2
    2
    1 2
    0
    1
    1
    1
    
    Expected output
    1
    
  3. Example 3

    Input
    swi's cake is missing!
    2
    1
    1
    0
    1
    2
    0
    
    Expected output
    1 2