SAC has
Recently, Mr. DeMello was tasked with monitoring friends and the friend-distance between them. The friend-distance is the minimum amount of friendships required to travel between two friends.
However, Mr. DeMello discovered that friendships could be destroyed, and all the current friendships would be destroyed eventually.
The school administrators ask Mr. DeMello
1 u v
: Output the friend-distance between friend -1
if they are not connected by friends.
2 u v
: Remove the friendship between friend
Since Mr. DeMello wants to get a raise, he has decided to ask you to kindly help him.
Can you do it?
Constraints
For all subtasks:
Every friend can reach every other friend before any friendships are destroyed.
Every friendship will be deleted once in the queries.
Subtask 1 [30%]
Subtask 2 [70%]
Input Specification
The first line will contain
The next
The next
Output Specification
For each type -1
if they cannot reach each other through friends.
Sample Input
5 8
1 2
3 2
4 5
4 1
1 1 3
2 2 3
1 1 3
2 4 1
1 5 3
1 1 2
2 1 2
2 4 5
Sample Output
2
-1
-1
1
Comments