#Q104. 「一本通 3.6 练习 3」旅游航道
「一本通 3.6 练习 3」旅游航道
Description
The SGOI Tourism Bureau has launched travel services in the SG-III star cluster, attracting tens of thousands of Earth visitors daily, including the UN Secretary-General, presidents of various countries, and the director of the SGOI Headquarters. The travel routes are extensive, with numerous passenger spacecraft shuttling between the planets in the cluster daily, ensuring that any two planets are always reachable via routes.
However, due to recent financial difficulties and the aging of some spacecraft, coupled with insufficient funds to purchase new ones, some routes have to be canceled. If the deletion of a certain route makes some planets unreachable, then this route cannot be deleted and is referred to as a "main route".
The director of the SGOI Tourism Bureau wants to know the number of main routes. Given the large number of routes, manual calculation is impractical. Therefore, he has commissioned you to write a program to compute the number of main routes.
Input Format
The input file contains several sets of data.
The first line of each set of data contains two numbers, and . The planets are numbered from to .
The following lines each describe a route with two integers and , indicating that there is a route from planet to planet . The data is provided by the SGOI Tourism Bureau, and you do not need to worry about errors in the data.
The input file ends with a line containing 0 0.
Output Format
The output file consists of lines, where the -th line contains a single number representing the number of main routes for the -th set of input data.
Sample 1
2 1
1 2
0 0
1
Data Range and Hints