#Q102. 「一本通 3.6 练习 1」网络

「一本通 3.6 练习 1」网络

Description

Original Source: CEOI 1996

A telephone line company (referred to as TLC) is establishing a new telephone cable network. They have connected several locations, each numbered uniquely from 11 to NN. The cables are bidirectional and enable communication between any two locations. Each location has a telephone switch where the cables terminate. From any location, it is possible to reach any other location through the cables, though not necessarily directly—communication may pass through multiple switches.

Occasionally, power failures at a location cause its switch to stop functioning. TLC staff have realized that unless the location is unreachable, this failure can disrupt communication between some other locations. In such cases, the location where the failure occurs is termed a critical point. The staff now want to write a program to count the number of such critical points. Help them accomplish this.

Input Format

The input file consists of multiple test cases.

Each test case represents a network. The first line of each test case is the total number of locations NN. This is followed by up to NN lines, each describing a location and the numbers of the locations it is directly connected to. These lines fully describe the network, ensuring that every direct connection between two locations is included in at least one line. All numbers on a line are separated by spaces. Each test case ends with a single line containing 0. The final block of input consists of a single line with N=0.

Output Format

For each test case except the last one, output the number of critical points on a separate line.

Sample 1

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

1
2

Constraints and Hints

N<100N<100