Problem V
Railroad Map
The Slovak national railroad company has recently built new tracks. They want to update their railroad map according to these changes. But they want the map to be as simple as possible. So they decided to remove from the map all the stations that have exactly two other direct connections to other stations (i.e., a single railroad passing through the station).
You will be given the complete map of Slovak railroads. It
consists of railway stations numbered from 1 to
Input
The first line of the input file contains an integer
Each test case begins with a line with two integers
You can assume that in each test case there is a path between every two stations. Also, there will always be at least 2 stations that are not directly connected to exactly two other stations.
Output
For each test case, the output shall consist of multiple
lines. The first line shall contain a positive integer
Print a blank line between outputs for different test cases.
Sample Input 1 | Sample Output 1 |
---|---|
2 3 2 1 2 1 2 3 1 4 4 1 2 1 2 3 2 3 4 3 4 2 1 |
1 1 3 2 2 1 2 1 2 2 6 |