In the event of technical difficulties with Szkopuł, please contact us via email at email@example.com.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
The International X-Game Federation organises a tournament in which programmes that play this game participate. programmes numbered from to take part in the competition. The rules of the tournament are as follows: while there remains more than one programme in the tournament, two of them (distinct) are randomly chosen to play a game. The defeated one (there are no draws in the X-Game) drops out of the tournament and the whole procedure is repeated. The sole programme which stays in the tournament after all games have been played is the winner.
The federation has a table of results of previous tournaments. It is known, that the programmes play deterministically (i.e. in repeatable fashion) and in exactly the same way as in previous tournaments. So, if two programmes have already played one against another then their next game will end with the same result. If, however, they have never played against each other, the outcome of the game cannot be predicted - both have a chance of winning. The federation would like to know a list of all programmes which have a chance of winning the tournament.
Write a programme which:
The first line of the input contains an integer , . The next lines contain the table of results of previous games: 'st line contains an integer , , followed by numbers of programmes, not equal to , in increasing order - those are the numbers of programmes, with which the programme has previously won. The numbers in lines are separated by single spaces. The number of all known results of previous games does not exceed .
The first and only line of the standard output should contain the number of programmes which have a chance of winning the tournament, followed by numbers identifying those programmes, in increasing order. The numbers should be separated by single spaces.
For the input data:
4 2 2 3 0 1 2 1 2
the correct result is:
3 1 3 4
Task author: Bartosz Walczak.