{"problem":{"name":"Ki","description":{"content":"Given is a rooted tree with $N$ vertices numbered $1$ to $N$. The root is Vertex $1$, and the $i$\\-th edge $(1 \\leq i \\leq N - 1)$ connects Vertex $a_i$ and $b_i$. Each of the vertices has a counter i","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc138_d"},"statements":[{"statement_type":"Markdown","content":"Given is a rooted tree with $N$ vertices numbered $1$ to $N$. The root is Vertex $1$, and the $i$\\-th edge $(1 \\leq i \\leq N - 1)$ connects Vertex $a_i$ and $b_i$.\nEach of the vertices has a counter installed. Initially, the counters on all the vertices have the value $0$.\nNow, the following $Q$ operations will be performed:\n\n*   Operation $j$ $(1 \\leq j \\leq Q)$: Increment by $x_j$ the counter on every vertex contained in the subtree rooted at Vertex $p_j$.\n\nFind the value of the counter on each vertex after all operations.\n\n## Constraints\n\n*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq Q \\leq 2 \\times 10^5$\n*   $1 \\leq a_i < b_i \\leq N$\n*   $1 \\leq p_j \\leq N$\n*   $1 \\leq x_j \\leq 10^4$\n*   The given graph is a tree.\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $Q$\n$a_1$ $b_1$\n$:$\n$a_{N-1}$ $b_{N-1}$\n$p_1$ $x_1$\n$:$\n$p_Q$ $x_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc138_d","tags":[],"sample_group":[["4 3\n1 2\n2 3\n2 4\n2 10\n1 100\n3 1","100 110 111 110\n\nThe tree in this input is as follows:\n![image](https://img.atcoder.jp/ghi/c771b2231be06af79a9994cbe6867552.png)\nEach operation changes the values of the counters on the vertices as follows:\n\n*   Operation $1$: Increment by $10$ the counter on every vertex contained in the subtree rooted at Vertex $2$, that is, Vertex $2, 3, 4$. The values of the counters on Vertex $1, 2, 3, 4$ are now $0, 10, 10, 10$, respectively.\n*   Operation $2$: Increment by $100$ the counter on every vertex contained in the subtree rooted at Vertex $1$, that is, Vertex $1, 2, 3, 4$. The values of the counters on Vertex $1, 2, 3, 4$ are now $100, 110, 110, 110$, respectively.\n*   Operation $3$: Increment by $1$ the counter on every vertex contained in the subtree rooted at Vertex $3$, that is, Vertex $3$. The values of the counters on Vertex $1, 2, 3, 4$ are now $100, 110, 111, 110$, respectively."],["6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10","20 20 20 20 20 20"]],"created_at":"2026-03-03 11:01:13"}}