You are the commander of a small militia fighting in a war-torn country. The country can be represented as
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.
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.
Input Specification
The first line of input will contain an integer
The next u v
, denoting a bidirectional road between city
The next line will contain
The next 1 A B
and type 2 events will be in the form 2 A
.
Output Specification
For each event of type 2, output
Constraints
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
Subtask 4 [55%]
No additional constraints.
Sample Input
5
1 2
2 3
2 4
4 5
3
2 2
1 5 3
2 2
Sample Output
5
1
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.
Comments