SOLVE
LATER
Trystland is a country with n cities and m weighted undirected roads such that there is atleast one possible path between any two cities. It is guaranteed that there is atmost one road between any two cities. However, due a to a difference in opinion on how the national number of the country should be decided, the people in Trystland have decided to separate into two countries. You have been assigned the duty to carry out the separation process in a peaceful way.
You have to divide the cities of Trystland into two countries A and B such that there is no path from any city in country A to any city in country B. However, there should still be atleast one path between any two cities of country A and any two cities of country B using the orignal roads of Trystland. The only operation that you are allowed to perform is to remove any one road of Trystland and then assign each city to either country A or country B.
Country A wants their national number to be weight of minimum spanning tree of all roads in country A whereas Country B wants their national number to be the weight of maximum spanning tree of all roads in country B. To make sure that the separation process is peaceful, you have to remove the road in such a way that the absolute difference between the national numbers of the two countries is as low as possible.
Input
The first line of the input contains two space separated integers n and m, the number of cities in Trystland and the number of roads in Trystland respectively.
The next m line contains three space separated integers u,v and w in each line where w is the weight of the road between u and v respectively.
Output
If there's no way to carry out the separation satisfying the required conditions of the process print -1 otherwise print the minimum absolute difference between the national numbers of the two countries in a single line.
Constraints