Our fellow friend has always wanted to become a manager. Because he is from a rich family, he decided to build and own a data center.
A data center is represented as a system of servers which are connected by cables bidirectionally. Each cable has a capacity of data that can be sent from a server to another. Also, each server has a coefficient of corruption, which is initially . In a span of a full day, there are events of the following types which take place:
- : The Gronzi Virus gets installed on the server and starts to corrupt the data center. For each server that is reachable from the server by going through cables with a capacity of data less than or equal to , it will increase their coefficient of corruption by .
- : The data center manager wants to get another big sponsorship and has to choose a server from the interval . To increase his chance to get even richer, he wants to find out the smallest coefficient of corruption for such a server.

Because our fellow friend has a lot of other work to do, help him get that big sponsorship.
Input data
The first line contains the integers , and .
On each of the following lines, there are three integers , and , which represent a bidirectional cable from server to server with a capacity of data equal to .
On each of the following lines, the events are being described. The first integer, , represents the type of the event. If , then the following three integers, , and , represent the corresponding type event. Similarly, if , then the following two integers, and , represent the corresponding type event.
Output data
You need to write on separate lines the smallest coefficient of corruption of a server from the corresponding interval of each type event.
Constraints and clarifications
- .
- .
- .
- for each .
- for each .
- for each .
- for each .
- for each .
- for each .
| # | Score | Constraints |
|---|---|---|
| 0 | 0 | Examples. |
| 1 | 10 | , . |
| 2 | 25 | The servers are connected in a line: . |
| 3 | 25 | for each . |
| 4 | 20 | for each . |
| 5 | 20 | No additional restrictions. |
Example
stdin
7 7 6
0 1 1
0 2 4
2 1 3
1 3 1
2 3 2
4 2 3
6 5 3
1 0 2 1
1 6 3 4
2 0 6
2 5 6
1 4 2 5
2 3 4
stdout
0
4
1
Explanation
Let be the initial coefficients of corruption for each of the servers.
After the first event, (starting from , we can reach servers , , , but not , because the capacity of data between and is greater than ).
After the second event, (starting from , we can reach server ).
The third event asks us the minimum value in , which is .
The fourth event asks us the minimum value in the interval in , which is .
After the fifth event, (we can't reach any other server starting from ).
The sixth event asks us the minimum value in the interval in , which is .