Customs duties-1
Recently, the queen of country AlgoLand invented a new way of laundering money for his royal court. She decided that every citizen who wishes to travel from one city to another country, should pay for this wish with their money.
There is AlgoLand n cities, numbered from 1 to n. Some cities are connected by roads, traffic which is allowed in both directions. Since traffic on any road, the traveler must get to the end.
Suppose now that a resident of the country wants to make a trip out of town A to town B. The new decree of Queen says that when driving on any road of the country during this trip, the police can take from this resident of customs duties in favor of the royal court (or may not take). If this resident have enough money to pay a fee, it automatically goes to prison. The decree also sets the amount of fees for each road of the country. Since the Queen is concerned about the inhabitants of the country, it forbade the police to take a tax resident in more than once during a single trip.
Note that if there are several ways to get from city A to city B, then the resident can choose to travel any one of them on their own.
Write a program that:
enters from the input file description of towns and roads in the country, as well as the number of initial and final trip of the city;
determines what the minimum amount of money should take a resident to not guaranteed to be imprisoned during the trip;
and outputs the result.
Input
The first line contains the numbers n and m (2 ≤ n ≤ 10000, 1 ≤ m ≤ 100000), separated by a space - the number of cities and roads. The following m lines describe the road. Each line describes one way and contains three numbers x, y, z (1 ≤ x, y ≤ n; x ≠ y; 1 ≤ z ≤ 10^9
) separated by spaces, meaning that the road connects the town of x and y and the fee for its passage is z currency units. The last line contains the numbers A and B (1 ≤ A, B ≤ n; A ≠ B) - number of initial and final urban travel. It is guaranteed that there exists at least one way to travel from A to B.
Output
Print the minimum amount of money that should take a resident to be able to travel from city A to city B, and thus guaranteed not to go to jail regardless of what the police officers.