Given a graph, support the following two operations:
Query(a_i, b_i, w_i)
: Does there exist a path from a_i
to b_i
using only edges with weight at least w_i
?
Update(m_i, x_i)
: Update the weight of edge m_i
to be x_i
.
Constraints
For 2 marks, there will be no update operations.
For 3 additional marks,
Input Specification
The first line will contain two space-separated integers,
The next
The next line will contain a single integer
Each of the next
An update operation, which can happen at most 2000 times, will take the form 1 m_i x_i
A query will take the form 2 a_i b_i w_i
Note that the operations happen in the order specified in the input.
Output Specification
For each query, print on a separate line 1
if the answer to the query is yes, and 0
otherwise.
Sample Input
3 4
1 2 3
2 3 3
2 1 1
1 2 1
6
2 1 2 4
2 2 3 2
1 1 4
2 1 2 4
1 2 1
2 2 3 2
Sample Output
0
1
1
0
Comments