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 n, followed by the information of each one: the name, the number
m_(i) of his or her affairs, and the m_(i) names of the corresponding
people. Assume that all the names are different, that for every pair of
names x and y, if x is in the list of y then x exists and y is in the
list of x, and that x is never in the list of x. Suppose 2 ≤ n ≤ 10⁴,
and that the total number of affairs is at most 2n.

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
