CF1891F A Growing Tree
Description
You are given a rooted tree with the root at vertex $ 1 $ , initially consisting of a single vertex. Each vertex has a numerical value, initially set to $ 0 $ . There are also $ q $ queries of two types:
- The first type: add a child vertex with the number $ sz + 1 $ to vertex $ v $ , where $ sz $ is the current size of the tree. The numerical value of the new vertex will be $ 0 $ .
- The second type: add $ x $ to the numerical values of all vertices in the subtree of vertex $ v $ .
After all queries, output the numerical value of all of the vertices in the final tree.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first case, the final tree with the assigned numerical values will look like this:
 The final tree with the assigned numerical values