405297: GYM101875 F Number Preference
Description
Laërdos is organizing a party and invited all his N mathematician friends. He decided to decorate his party with positive integers, ranging from 1 to 1018. He's now struggling to choose the integers that he's going to use because his friends are very picky about numbers.
He talked to all his friends beforehand, and they all told him their preferences. Each one of them described their preference by either:
- Listing the integers that they like, meaning that they hate all other integers; or
- Listing the integers that they hate, meaning that they like all other integers.
He wants to know how many integers he can use that will please all his friends.
InputThe first line of the input contains a single integer N (1 ≤ N ≤ 105) indicating the number of friends that were invited to the party.
Each of the following N lines describes the preferences of each friend. The i-th line contains the preferences of the i-th friend and has the following format:
t s l1 ... ls
t is 1 if the friend listed the integers that he or she likes and 2 otherwise. s (1 ≤ s ≤ 105) indicates the number of integers that were listed. It is followed by s integers l1... ls (1 ≤ lj ≤ 1018), indicating the integers that the friend listed.
The total number of integers listed by all friends is not greater than 2 × 105.
OutputOutput a single integer, the number of integers that all Laërdos' friends like.
ExamplesInput3Output
1 3 1 2 3
2 1 1
1 3 1 2 4
1Input
5Output
1 3 1 2 3
1 3 1 2 4
1 3 1 2 5
1 3 1 2 7
2 1 8
2Input
2Output
1 2 10 11
2 2 10 11
0