The map of the forest represents a rooted tree, where the vertices are clearings, the edges are paths between them, and the weight of an edge is the popularity of these paths. All clearings are numbered from $$$1$$$ to $$$n$$$.
Hedgehog Shurshik lives in the clearing located at the root vertex number $$$1$$$. During each of his walks, the hedgehog starts from vertex $$$1$$$ and goes to the leaf vertices for the tastiest apples, but only via a pleasant path. A pleasant path in the tree is a path from the root vertex to a leaf vertex such that at each descent, the hedgehog chooses the least popular road (i.e., descends along the edge with the smallest popularity value, and if there are several, to the vertex with the smallest number). A vertex is called a leaf if it has exactly one outgoing path and is not the root.
Shurshik made $$$q$$$ walks, each of which followed several rules: first, the hedgehog found a pleasant path, then added $$$+1$$$ to the popularity of all edges on the path. Help Shurshik determine how many times he will visit each leaf vertex.
Each test consists of several testcases. The first line contains a single integer $$$t~(1 \le t \le 10^4)$$$ — the number of testcases. The following describes the testcases.
The first line contains two integers $$$n$$$ and $$$q$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$0 \le q \le 10^{18}$$$) — the number of vertices in the tree and the number of walks made by Shurshik.
The next $$$n-1$$$ lines describe the edges of the tree. Each line contains three integers $$$u_i$$$, $$$v_i$$$, $$$w_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$0 \le w_i \le 10^{18}$$$) — the numbers of the vertices connected by the path and its initial popularity.
It is guaranteed that the sum of $$$n$$$ across all tests does not exceed $$$2 \cdot 10^5$$$ and the given graph is a tree with vertex $$$1$$$ as the root.
For each testcase, output the information about the visits to the leaf vertices.
For each leaf vertex in ascending order of its number, output on a separate line two numbers: the leaf number and the number of times Shurshik visited this leaf during all $$$q$$$ walks.
| Group | Points | Additional Constraints | Required Groups |
| 1 | 12 | $$$\sum n \cdot q \le 2 \cdot 10^5$$$ | – |
| 2 | 13 | $$$t = 1$$$; $$$n \le 20$$$; $$$w_i = 0$$$ | – |
| 3 | 20 | $$$u_i = \lfloor \frac{i+1}{2} \rfloor$$$, $$$v_i = i+1$$$ | – |
| 4 | 20 | $$$w_i = 0$$$ for all edges | 2 |
| 5 | 15 | $$$u_i = 1$$$, $$$v_i = i+1$$$ | – |
| 6 | 20 | No additional constraints | 1, 2, 3, 4, 5 |
45 71 2 01 3 13 4 53 5 34 5991 2 3001 3 4001 4 20012 9961791791 2 01 3 03 4 03 5 03 6 06 7 06 8 06 9 06 10 010 11 010 12 07 7771 2 01 3 02 4 02 5 03 6 03 7 0
2 44 15 22 2003 1004 2992 4980895904 1660298635 1660298637 415074668 415074669 4150746611 2075373312 207537324 1955 1946 1947 194
$$$\lfloor \frac{a}{b} \rfloor$$$ means rounding down the result of the division $$$\frac{a}{b}$$$. Thus, $$$\lfloor \frac{9}{10} \rfloor$$$ = 0 and $$$\lfloor \frac{1}{10} \rfloor$$$ = 0.
| Name |
|---|


