#abc187e. [abc187_e]Through Path
[abc187_e]Through Path
Problem Statement
We have a tree with vertices and edges, where the vertices are numbered and the edges are numbered . Edge connects Vertices and .
Each vertex in the tree has an integer written on it. Let be the integer written on Vertex . Initially, .
You will be given queries. The -th query, consisting of integers , , and , is as follows:
- If : for each Vertex reachable from Vertex without visiting Vertex by traversing edges, replace with .
- If : for each Vertex reachable from Vertex without visiting Vertex by traversing edges, replace with .
After processing all queries, print the integer written on each vertex.
Constraints
- All values in input are integers.
- The given graph is a tree.
Input
Input is given from Standard Input in the following format:
Output
Print the values after processing all queries, each in its own line.
Sample Input 1
Sample Output 1
In the first query, we add to each vertex reachable from Vertex without visiting Vertex , that is, Vertex .
In the second query, we add to each vertex reachable from Vertex without visiting Vertex , that is, Vertex .
In the third query, we add to each vertex reachable from Vertex without visiting Vertex , that is, Vertex .
In the fourth query, we add to each vertex reachable from Vertex without visiting Vertex , that is, Vertex .