IMPC16 Group Contests |
Start: Jan.16.2016 at 10:00:00 AM
Finish: Jan.16.2016 at 02:00:00 PM
The contest is finished!
• Contest scoreboard
|
Feedback | If you notice incorrect translations in Contester, please let author know.
|
|
Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Faruk Bulut.
Albanian Coders
The Albanian students, who have been studying for
the Olympiads in Informatics, gather around in the
school and study on new topics. They have been
practicing by typing codes for the Olympiad
competitions.
A prominent member of the community is the
hardworking student, Ali abi. Every evening,
if Ali is present, he teaches a brand new Olympiad
subject that no other student has heard before,
and no other topic is thought that night. In the
event that Ali is not present, other students
learn without him and exchange (teach each other)
all knowledge (topics) that they know.
Question:
Given the list of students present for D
consecutive camp days, output all students
that know all topics
learned during that period.
Input specification:
The first line of input contains an integer N,
1 <= N <= 100, the number of students. The students
are
numbered 1 to N. Student number 1 is Ali.
The second line contains an integer D, 1 <= D <=
50, the number of camp days.
The next D lines contain the list of students
present on each of the D days. Each line begins
with a
positive integer K, 2 <= K <= N, the number of
students present that day, followed by K positive
integers separated by spaces representing the
students.
No student will appear twice in one day and Ali
will appear at least once across all nights.
Output specification:
Output all students that know all topics,
including Ali, one integer per line in ascending order.
Sample Input I
4
3
2 1 2
3 2 3 4
3 4 2 1
|
Sample Input II
8
5
4 1 3 5 4
2 5 6
3 6 7 8
2 6 2
4 2 6 8 1
|
Sample Input III
5
3
2 1 3
2 2 1
4 2 1 4 5
|
Sample Output I
1
2
4
|
Sample Output II
1
2
6
8
|
Sample Output III
1
|
Для отправки решений необходимо выполнить вход.
|