НВП + DSU
In one country there are n cities, some of which are connected by two-way routes. Cities are numbered by integers from 1 to n. In times of financial crisis the level of the crime in a state rose and the crime groups are organized. The most dangerous of these was "Timur and his gang" led by a notorious criminal circles by Timur, that commit robberies on most of the roads. As a result, some roads became dangerous to drive.
Baha must get out of city 1 and go to city n. Since he appreciate his life too much (and his wallet also), he decided to cheat Timur and go to destination by the least dangerous route, even if it is not the shortest. Baha defined the level of the danger for each road as an integer from 0 (safe) to 1,000,000 (very dangerous). The danger of the route is the maximum value among the dangers of the roads that make up this route.
Help him to choose the safest route (one which has the minimum possible risk).
The first line contains two integers n and m (2 ≤ n, m ≤ 1000000). Each of the next m lines defines one road and contains three integers:
a, b (1 ≤ a, b ≤ n) - cities, connected with the road; c (0 ≤ c ≤ 1000000) - the danger of the road.
Any two cities can be connected by several roads. The numbers in the rows are separated by spaces.
One integer - the danger of the most safe route.
3 2 1 2 1 2 3 1