The FME graph (2)

Lisbeth Salander (one of the main characters of the famous trilogy Millennium) is a crack mathematician, and therefore she is considering enrolling in the FME. As she likes both men and women, and she knows the FME graph, she is curious to know if it is possible that all the affairs have been between people of opposite sex. Help her!

Input

Input consists of several cases. Every case begins with the number of people nn, followed by the information of each one: the name, the number mim_i of his or her affairs, and the mim_i names of the corresponding people. Assume that all the names are different, that for every pair of names xx and yy, if xx is in the list of yy then xx exists and yy is in the list of xx, and that xx is never in the list of xx. Suppose 2n1042 \le n \le 10^4, and that the total number of affairs is at most 2n2n.

Output

For every case, tell if it is possible that all the affairs have been between people of opposite sex.

Problem information

Author: Ferran Alet i Ivan Geffner

Generation: 2026-01-25T10:26:15.033Z

© Jutge.org, 2006–2026.
https://jutge.org