Bruce is designing an escape maze game for his students. The maze can be treated as an undirected graph. Each vertex in the graph is a room, and there are hallways (edges) that connect two rooms together. Each room has at least one hallway connecting it to some other room. Some rooms in the maze are set as exits. Initially, students may start from any room, and they need to find a path to any exit to escape the maze. But Bruce doesn't want the game to be too easy. So, he decides to close one room during the game. However, Bruce has to ensure that, no matter which room is closed, there always exists a path to one exit for any student in the maze. Please write a program to help Bruce to decide the least number of required exits in the maze and the number of different ways to place the exits. Two ways of placing exits are different if any room is an exit in the one way but it isn't in the other way.
Note: Bruce can only close one room during the game, and the closed room may be an exit. Also, the graph may be initially disconnected.
Input Specification
The input includes multiple test cases, up to .
The first line of input will consist of an integer , which is the number of hallways.
Each of the next lines will consist of two integers and , which are two rooms connected by a hallway.
The input is terminated by a single .
Output Specification
For each test case in the input, output two integers on a single line. The first integer is the least number of required exits to make sure that, no matter which room is closed by Bruce, there is always a path to one exit for any student in the maze. The second integer is the number of different ways to design the maze with the least number of exits.
Both output numbers will be less than .
Sample Input
9
1 3
4 1
3 5
1 2
2 6
1 5
6 3
1 6
3 2
6
1 2
1 3
2 4
2 5
3 6
3 7
0
Sample Output
2 4
4 1
Explanation of Output for Sample Input
The least number of exits for case 1 is 2. There are 4 different ways to place the two exits: , , , .
The least number of exits for case 2 is 4. There is only 1 way to place the four exits: .
Comments
1) Multiple Hallways between the same rooms?
2) Selfloops
1) there may be multiple hallways between rooms
2) no selfloops. each hallway connected two rooms (not same room).
Well neither is specified, so assume yes
Is it just me or would (1, 4) be a valid exit placement for the first case?
Close room 1, and you can't reach an exit from room 2,3,5,6