Gronzi Virus

Time limit: 10sMemory limit: 256MBInput: Output:

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 NN servers which are connected by MM 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 00. In a span of a full day, there are QQ events of the following types which take place:

  • 1 X K V1\ X\ K\ V: The Gronzi Virus gets installed on the server XX and starts to corrupt the data center. For each server that is reachable from the server XX by going through cables with a capacity of data less than or equal to KK, it will increase their coefficient of corruption by VV.
  • 2 L R2\ L\ R: The data center manager wants to get another big sponsorship and has to choose a server from the interval [L,R][L,R]. To increase his chance to get even richer, he wants to find out the smallest coefficient of corruption for such a server.

In a world full of data centers, there has to be a vulnerability!\text{In a world full of data centers, there has to be a vulnerability!}

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 NN, MM and QQ.

On each of the following MM lines, there are three integers aia_i, bib_i and cic_i, which represent a bidirectional cable from server aia_i to server bib_i with a capacity of data equal to cic_i.

On each of the following QQ lines, the events are being described. The first integer, TiT_i, represents the type of the event. If Ti=1T_i=1, then the following three integers, XiX_i, KiK_i and ViV_i, represent the corresponding type 11 event. Similarly, if Ti=2T_i=2, then the following two integers, LiL_i and RiR_i, represent the corresponding type 22 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 22 event.

Constraints and clarifications

  • 1≤N≤100 0001 \le N \le 100\ 000.
  • 1≤M≤200 0001 \le M \le 200\ 000.
  • 1≤Q≤100 0001 \le Q \le 100\ 000.
  • 0≤ai,bi≤N−10 \le a_i,b_i \le N-1 for each i=0,…,M−1i=0,\ldots,M-1.
  • 1≤ci≤2 000 000 0001 \le c_i \le 2\ 000\ 000\ 000 for each i=0,…,M−1i=0,\ldots,M-1.
  • 1≤Ti≤21 \le T_i \le 2 for each i=0,…,Q−1i=0,\ldots,Q-1.
  • 0≤Xi≤N−10 \le X_i \le N-1 for each i=0,…,Q−1i=0,\ldots,Q-1.
  • 0≤Li≤Ri≤N−10 \le L_i \le R_i \le N-1 for each i=0,…,Q−1i=0,\ldots,Q-1.
  • 1≤Ki,Vi≤2 000 000 0001 \le K_i,V_i \le 2\ 000\ 000\ 000 for each i=0,…,Q−1i=0,\ldots,Q-1.
# Score Constraints
0 0 Examples.
1 10 N≤5 000N \le 5\ 000, Q≤5 000Q \le 5\ 000.
2 25 The servers are connected in a line: 0−1−2−…−(N−1)0-1-2-\ldots-(N-1).
3 25 Li=RiL_i=R_i for each i=0,…,Q−1i=0,\ldots,Q-1.
4 20 Ki=2 000 000 000K_i=2\ 000\ 000\ 000 for each i=0,…,Q−1i=0,\ldots,Q-1.
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 C=[0,0,0,0,0,0,0]C=[0,0,0,0,0,0,0] be the initial coefficients of corruption for each of the 77 servers.

After the first event, C=[1,1,1,1,0,0,0]C=[1,1,1,1,0,0,0] (starting from 00, we can reach servers 11, 22, 33, but not 44, because the capacity of data between 22 and 44 is greater than 22).

After the second event, C=[1,1,1,1,0,4,4]C=[1,1,1,1,0,4,4] (starting from 66, we can reach server 55).

The third event asks us the minimum value in CC, which is 00.

The fourth event asks us the minimum value in the interval [5,6][5,6] in CC, which is 44.

After the fifth event, C=[1,1,1,1,5,4,4]C=[1,1,1,1,5,4,4] (we can't reach any other server starting from 44).

The sixth event asks us the minimum value in the interval [3,4][3,4] in CC, which is 11.

Log In or Sign Up to be able to send submissions!