Tree Climber
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

Given a rooted tree with n nodes. Each edge has a weight and initially all weights are 0.
You need to perform m operations. In each operation you are given three integers l,r,x, which means you need to find the smallest connected component in the tree that contains all nodes in the range [l,r], and add x to the weights of edges in this connected component.
After all operations are performed, output the weights of all edges.

输入描述:

The first line contains two integers n,m.
The following n-1 lines each contain two integers u,v representing that there's an edge between u and v on the tree.
The following $m$ lines each contains three integers l,r,x representing an operation.

输出描述:

Output n-1 lines. The i-th line contains an integer representing the final weight of the i-th edge in the input order.
示例1

输入

复制
6 3
1 2
1 3
2 4
2 5
5 6
3 5 1
4 6 10
1 2 100

输出

复制
101
1
11
11
10

说明

For the first operation, the smallest connected component contains vertices 1,2,3,4,5.
For the second operation, the smallest connected component contains vertices 2,4,5,6.
For the third operation, the smallest connected component contains vertices 1,2.

备注:

1\le n\le3\times10^5, 0\le m\le10^61\le u,v\le n,u\ne v, 1\le l\le r\le n, 1\le x\le10^9.