- Time limit: 2.00 s
- Memory limit: 512 MB
Uolevi is working for a construction company that delivers pre-built components to the construction site. As the components can get very wide, it is important to know the maximum width limits for deliveries.
There are locations numbered and bidirectional roads numbered connecting them. The -th road connects locations and and has width . It is guaranteed that there exists a path between every pair of locations.
The construction company's factory is in location 1. Find the maximum delivery width that can reach each of the locations.
Input
The first line contains two integers and . The -th of next following lines contains three integers , , and .
Output
Print the maximum widths that can reach the locations other than the factory in a line, separating with space, like below:
Constraints
- if
Example 1
Input:
5 5 1 5 8 2 3 5 2 5 10 3 4 4 3 5 6
Output:
8 6 4 8
Example 2
Input:
10 15 1 2 6 1 5 5 2 3 5 2 6 9 2 7 2 3 4 1 3 5 10 3 7 6 3 9 3 4 10 1 5 6 3 5 9 5 6 8 2 6 9 1 7 8 2
Output:
6 5 1 5 6 5 2 5 1