Highest Paid Toll

In Dhaka there are too many vehicles. So, the result is well known, yes, traffic jam. So, mostly people have to spend a long time in the roads to go from one place to another. But who knows, what can be the solution. Now, the Casual Students in Engineering from Dhaka University (CSEDU) have finally found a solution to this problem. The idea is to make all the roads one way. That means a vehicle can go through the road in one way. And to make the number of vehicles low, each vehicle has to pay a toll to use a road. Now you are a member of CSEDU, and you want to go from a place s to another place t. And you have a total of p taka in your pocket. Now you want to find the road that takes the highest toll, to go from s to t. Remember that you can’t use more than p taka. Forthepictureabove,s=1,t=5andp=10. Therearethreepathsfrom1to5 Path1: 1->2->5,totaltoll=11(>p) Path2: 1->3->5,totaltoll=9(≤p),6isthemaximumtoll Path3: 1->4->5,totaltoll=9(≤p),5isthemaximumtoll So the maximum toll for a road of all of the paths having total toll ≤ p is 6. Input The first line of the input file contains an integer T (T ≤ 50) which denotes the total number of test cases. The description of each test case is given below: Each case starts with five integers N (2 ≤ N ≤ 10000), M (1 ≤ M ≤ 100000), s (1 ≤ s ≤ N), t (1 ≤ t ≤ N) and p (1 ≤ p ≤ 106). Then there are M lines each containing three integers u, v and c. u and v are place numbers and there is a road from u to v (1 ≤ u,v ≤ N, u ̸= v) and c (0 ≤ c ≤ 105) is the toll needed for that road. Output For each line of input produce one line of output containing r. Where r is the maximum toll needed for a road to go from s to t where the path doesn’t need more than p taka toll or ‘-1’ if there is no such road.

2/2 Sample Input 2 5 6 1 5 10 127 254 136 353 145 454 2 1 1 2 10 1 2 20 Sample Output 6 -1