In the event of technical difficulties with Szkopuł, please contact us via email at firstname.lastname@example.org.
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.
There are clerks and commanders employed in Byteland Security Agency (BSA). The records of all the clerks can be found in the BSA archives. In each folder there is a signature of the clerk and signatures of workers (clerks or commanders), who vouche for his/her loyalty. Every newly engaged clerk has to obtain at least one guarantee. In the course of time, list of guarantors can increase. BSA has found out lately, that the circle of commanders has been infiltrated by a spy from hostile Microsoftland. Next spies were employed in BSA on clerks positions thanks to the guarantee of a spy-commander and/or other employed spies. Such spies have guarantees exclusively from workers being spies.
Reliability of a clerk can be questioned, if he has not indirectly got guarantees from any commander, who is not a spy, i.e. there is no such sequence of BSA workers , that is commander not being a spy, is given clerk and (for ) vouches for .
If an assumption that a commander is a spy, caused that reliability of a clerk became questioned, this clerk would be suspected of spying. The command of BSA would want to see the list of these clerks, as soon as possible!
Commanders: Alice, Gregor
Clerks: Bob (vouched for by Alice), Charlie (vouched for by Bob), David (vouched for by Bob and by Charlie), Eve (vouched for by Alice and Gregor), Frank (vouched for by Eve), Henry (vouched for by Gregor and Isabelle), Isabelle (vouched for by Gregor and Henry).
Suspected: Bob, Charlie, David, Henry, Isabelle.
Write a program which:
The first line of the standard input consists of exactly one positive integer , (), standing for the number of workers of BSA. The employees are numbered from 1 to n. The next lines contain descriptions of guarantees. In the ()-th line of the file there is the description of guarantees given to the -th worker. It is a sequence of integers separated by single spaces. The first number in this sequence , equals to the number of guarantees given to the -th worker. The next mi integers are the numbers of workers, who have guaranteed the truthfullness of the -th worker. (Thus the number of elements in the sequence in the ()-th line equals ). Commanders are those workers, who have not been vouched for by anybody.
Your program should:
For the input data:
9 0 1 1 1 2 2 2 3 2 1 7 1 5 0 2 7 9 2 7 8
the correct result is:
2 3 4 8 9
Task author: Marcin Kubica.