You are the commander of a small militia fighting in a war-torn country. The country can be represented as cities numbered through connected by bidirectional roads. It is possible to reach any city from any other city by going along the roads. Your force, while elite, is small. In order to not spread them out too thin, you are only concerned with choke points in the country. A road is a choke point if it is the only way to travel between any pair of cities. In graph theory, this is called a bridge or a cut edge.
You have just received intel that the enemy is mobilizing its forces to launch a surprise attack, as well as orders to eliminate them at all costs. Unfortunately, you do not know the location of the enemy, nor the location that they plan to attack. What's worse, your scouts are constantly discovering secret routes throughout the country that the enemy may use.
As the commander, you are holding an emergency strategy meeting. events will occur throughout the session, each of which is either type 1 or type 2.
Type 1: A scout runs in reporting that they have discovered a new direct secret route between cities and .
Type 2: You consider the following query: if the enemy is currently located at city , what is the expected number of choke points that they will have to pass through assuming that their target could be any of the cities (including ) with equal probability and that the enemy army never traverses the same road or route twice? Please read the output specification on the details of what to output for this query.
The first line of input will contain an integer .
The next lines will each contain a description of a road in the form
u v, denoting a bidirectional road between city and .
The next line will contain .
The next lines will each describe an event, where type 1 events will be in the form
1 A B and type 2 events will be in the form
For each event of type 2, output times the answer to the query on a separate line. That is, if the expected number of choke points is , you should output . It is guaranteed this will be an integer value.
For all subtasks:
There will be at least one type-2 event, so the output will not be empty.
Subtask 1 [15%]
Subtask 2 [20%]
There will be no type-1 events.
Subtask 3 [10%]
There will be no more than type-1 events.
Subtask 4 [55%]
No additional constraints.
5 1 2 2 3 2 4 4 5 3 2 2 1 5 3 2 2
Explanation of Output for Sample Input
After the type-1 event, the only road that is still a choke point is the road between cities 1 and 2.