HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > C. T. 2011 > problem:


Babel tower

Volume problems

• Word Statistics
• Brackets
• Profits
• Triangle
• Istanbul
• Butterfly
• Buying hay
• Fleas
• Babel tower
• Pizza delivery
• Railway turnout
• Door lock
• Maze
• Skiers
• Matrix
• Range Minimum Query
• Министерство правды

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 1000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.

Problem description

During the construction of the Babel tower, as you know, there were workers with different nationality and languages. As a result each person knew several languages and two people can pass each other information if there is a language which they both know. The head of construction knew only some famous languages and if someone didn't know any of them he asked other people to translate him. Determine how many people could finally understand orders.

Input

All languages are numbered from 1 to 50. We asume that first person is the head of construction.

Line 1: A single integer N (1 <= N <=100) number of workers

Line 2...N+1: ith line contains Li (how many languages he knows) and Li integers then (which languages he knows)

Output

Write number of people who understood orders.

Example

stdin stdout

5
2 1 2
1 1
2 2 3
0
2 4 5

3

8
3 1 4 8
3 2 4 15
3 12 14 19
2 14 33
2 8 11
4 2 4 18 21
1 15
2 21 23

6
Для отправки решений необходимо выполнить вход.

www.contester.ru