#P5886. Possible Champions

    ID: 19114 Type: Default 1000ms 256MiB

Possible Champions

Possible Champions

There are \(n\) problem setters and \(m\) contestants. Contestants are numbered from \(1\) to \(m\), and setters are numbered from \(1\) to \(n\). After registration, each setter \(i\) makes a prediction: "I believe that only these \(k_i\) contestants, namely \(a_{i,1},a_{i,2},\dots,a_{i,k_i}\), have a chance to finish first." All other contestants will definitely not finish first.

The setter of this problem, via a time tunnel, already knew who the eventual champion was. He then revealed all \(n\) predictions to you and informed you that exactly \(p\) of the predictions are correct (a prediction is correct if and only if the eventual champion is among the setter's list). Based on this, determine which contestants could possibly be the champion. Output their numbers in increasing order.

inputFormat

The first line contains three integers \(n\), \(m\), and \(p\) representing the number of problem setters, the number of contestants, and the number of correct predictions, respectively.

Then \(n\) lines follow. The \(i\)-th line starts with an integer \(k_i\) (the number of contestants that setter \(i\) believes can finish first), followed by \(k_i\) distinct integers \(a_{i,1}, a_{i,2}, \dots, a_{i,k_i}\) indicating the contestant numbers.

outputFormat

Output in one line all the possible champions' numbers in increasing order, separated by spaces.

sample

3 5 2
3 1 2 3
2 2 4
3 1 2 5
1