#P7234. Unique Actor Matching
Unique Actor Matching
Unique Actor Matching
JYY is a lover of opera and has a passion for art. He has seen all the photos of the n actors and read all their names (each name is unique), but he does not know which face corresponds to which name. The opera troupe performed m shows. In the i-th show, exactly k_i actors appear. During each performance, JYY can clearly identify the faces of the actors on stage. Also, from the playbill of the performance, he knows the set of names of the actors who performed, although he does not know the correspondence between the names and the faces.
After watching all m performances, JYY wonders whether the information he collected is enough to uniquely determine the matching between every actor's face and his/her name.
Note: The matching is unique if for every two different actors, their pattern of appearance across the performances is different. In other words, if we define a performance signature for each actor as a binary string of length m (with the i-th character being '1' if the actor appeared in the i-th performance and '0' otherwise), then the matching is unique if and only if all n signatures are distinct.
Your task is to help JYY determine whether the actor-name matching can be deduced uniquely.
inputFormat
The input begins with two integers n
and m
(1 ≤ n, m ≤ 1000), representing the number of actors and the number of performances, respectively.
Then m
lines follow. The i-th of these lines starts with an integer ki
(1 ≤ ki ≤ n), the number of actors in the i-th performance, followed by ki
distinct integers indicating the indices of the actors (each between 1 and n) who appear in that performance.
outputFormat
Output a single line containing Yes
if the matching between actors' faces and names can be uniquely determined; otherwise, output No
.
sample
3 2
2 1 2
2 2 3
Yes