The Rhodes Island operators are scouting out the new map for CCB#2. The map can be represented as a tree with $$$n$$$ nodes numbered from $$$1$$$ to $$$n$$$. Slugs of $$$m$$$ different colors exist, and there is one slug of color $$$i$$$ ($$$1 \le i \le m$$$) for each node on the shortest path from $$$s_i$$$ to $$$t_i$$$. Note that multiple slugs of different colors can be on the same node, and not all colors of slugs are initially on the map.
The slugs have a very particular behavior pattern where sometimes all the slugs of the same color will leave the map, or all the slugs of the same color will return to the map.
Ifrit is tasked with clearing out the slugs, so she will consider different plans of attack. A plan of attack is denoted by two nodes $$$u$$$ and $$$v$$$ in which she hits all the slugs on the shortest path from $$$u$$$ to $$$v$$$. If she hits any slug with color $$$i$$$, she adds $$$v_i$$$ to her score, where $$$v_i$$$ is a predetermined value for color $$$i$$$. Ifrit will not actually perform the attack, but she wants to know her score for each plan of attack.
You will have to process $$$q$$$ events, each one of the following three types:
The first line of input contains three integers $$$n$$$, $$$m$$$, and $$$q$$$ $$$(1 \leq n, m, q \leq 3 \cdot 10^5)$$$ — the number of nodes in the tree, the number of colors, and the number of events respectively.
The following $$$n-1$$$ lines each contain two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n, u \neq v)$$$, denoting an edge between nodes $$$u$$$ to $$$v$$$ in the tree. It is guaranteed that the inputted set of edges forms a valid tree.
The following $$$m$$$ lines each contain four integers $$$s_i$$$, $$$t_i$$$, $$$v_i$$$, and $$$c_i$$$ $$$(1 \leq s_i, t_i \leq n, 1 \leq v_i \leq 10^9, c_i \in \{0, 1\})$$$ — the start and end of the shortest path the slugs of the $$$i$$$-th color reside on, the value of hitting color $$$i$$$, and whether or not the slugs of color $$$i$$$ are present initially. If $$$c_i = 0$$$, they are not present; otherwise, if $$$c_i = 1$$$, they are.
The following $$$q$$$ lines outline events, each in one of the following formats:
—
Tests in subtasks are numbered from $$$1 - 20$$$ with samples skipped. Each test is worth $$$\frac{100}{20} = 5$$$ points.
Tests $$$1 - 2$$$ satisfy $$$n, m, q \leq 100$$$.
Tests $$$3 - 5$$$ satisfy $$$n, m, q \leq 1000$$$.
Tests $$$6 - 12$$$ satisfy $$$v_i = 1$$$ for all $$$i$$$.
The remaining tests do not satisfy any additional constraints.
For each attack plan (event of type $$$3$$$), output the score Ifrit will get if she follows the plan.
5 3 91 21 32 42 53 4 1 02 5 10 01 4 100 01 13 5 31 23 1 41 33 1 52 13 5 33 5 5
1 11 111 110 10
10 4 122 103 64 37 97 55 41 510 110 89 9 18 03 6 47 02 4 91 03 3 30 11 13 6 41 23 1 52 43 5 103 6 23 3 93 10 81 43 3 31 3
30 0 0 47 65 0 77
—
Problem Idea: willy108, hyforces
Problem Preparation: willy108
Occurrences: Advanced G
| Name |
|---|


