Directed Acyclic Graph

아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

Recently, Rikka showed great interest in the data structures for directed acyclic graphs (DAGs). She dreams that extending classic tree-based algorithms like "weighted-chain decomposition" to their counterparts based on DAGs will be perfectly cooooool!

Now, she came up with a simple problem, and she would like to invite you to solve this problem with her.

You are given an nn-node mm-edge DAG GG. Each node uu has a non-negative integer value val_u\mathit{val}\_u. All values are set to 00 initially.

Rikka wants to perform qq operations of three types described below:

  1. Given uu and xx, set val_v\mathit{val}\_v to xx for all vv reachable from uu;
  2. Given uu and xx, set val_v\mathit{val}\_v to minval_v,x\min\\{\mathit{val}\_v, x\\} for all vv reachable from uu;
  3. Given uu, print its current value val_u\mathit{val}\_u.

Can you perform all these operations fast enough?

A node vv is said to be reachable from uu if there is a path starting in uu and ending in vv. A path is a node sequence p_1,p_2,,p_kp\_1, p\_2, \ldots, p\_k satisfying (p_i,p_i+1)G(p\_i, p\_{i + 1}) \in G for each i=1,2,,k1i = 1, 2, \ldots, k - 1.

입력

The first line of input contains three integers nn, mm, qq (1n,m,q1051 \le n, m, q \le 10^5).

Then mm lines follow. Each of them contains two integers xx and yy, representing a directed edge (x,y)(x, y) in the graph (1x,yn1 \le x, y \le n). The input graph is guaranteed to be a DAG.

Then qq lines follow. Each of them contains two or three integers in one of the following three formats:

  • "1 u x" indicating the first type of operation;
  • "2 u x" indicating the second type of operation;
  • "3 u" indicating the third type of operation.

All parameters in the operations above satisfy 1un1 \le u \le n and 0x1090 \le x \le 10^9.

출력

For each operation of the third type, print a single line containing an integer: the current value of val_u\mathit{val}\_u.