Once upon a time, Nella lived in a peaceful village with buildings and roads, where it was possible to reach any building from any other. One day, a large earthquake struck and directed all the roads! Since communication is extremely important, Nella would like to establish one building as the town hall, where it is possible to reach any building from the town hall after redirecting some amount of roads. Even worse for the village is that the roads started to redirect themselves randomly due to the instability caused by the earthquake! Being in this horrible situation, Nella would like you to write a program for him that supports 2 types of operations:
1 b
: Nella would like to know how many roads he would have to redirect to make building the town hall.2 r
: Flip the direction of road .
Please help him before his village is destroyed!
Input Specification
The first line will contain 2 integers and , the number of buildings and the number of operations.
The next lines will contain 2 integers and , indicating a one-way connection from building to .
The next lines will contain 2 integers each. The first integer will be , the type of the operation. If is , will follow, indicating that the first operation will be performed on building . If is , will follow, indicating that the second operation will be performed on road . Note that the roads are identified by the order they are given in the input.
Output Specification
For the th type 1 operation, output one line containing the number of roads Nella would have to redirect to make the town hall.
Constraints
Sample Input
4 5
1 4
2 4
3 4
1 1
1 4
1 2
2 2
1 1
Sample Output
2
3
2
1
Explanation
Initially, the graph looks like this:
After the 4th operation, the graph looks like this:
Comments