Anisie, after suffering a series of successive disappointments at her former workplace, decides to escape the urbanism of Bucharest for that of Mizil. Mizil is kind of like New York in Romania. There, she finds a job as a tour guide.
Mizil can be described as a graph with $$$N$$$ tourist points and $$$M$$$ bidirectional streets connecting these points. Each street can be described by the points $$$x_i, y_i$$$ that it connects and a congestion value $$$c_i$$$, which indicates how unpleasant it is to traverse completely due to various factors, one of them being the presence of traffic jams. There can be no more than one street connecting any two touristic points.
Anisie organizes tours through Mizil. A tour is defined as a sequence of tourist points $$$t_1, t_2, \dots, t_k$$$, where any two successive tourist points are connected by a street. When planning these tours, two parameters must be taken into account:
Ideally, Anisie would minimize the discomfort and maximize the luminosity. However, since each tourist has different needs, she will have to determine, given Mizil's map, for $$$Q$$$ triplets $$$u_i, v_i, l_i$$$, what is the minimum discomfort possible for a tour that starts at $$$u_i$$$, ends at $$$v_i$$$, and has a luminosity level of at least $$$l_i$$$. If no such tour exists, the result will be $$$-1$$$.
On the first line, the numbers $$$N$$$, $$$M$$$ ($$$1 \le N \le 100\,000, 1 \le M \le 300\,000$$$) will be present, representing, in order, the number of tourist points in Mizil, and the number of streets connecting these points.
Next, $$$M$$$ lines follow, each containing $$$3$$$ integers, $$$x_i, y_i, c_i$$$ ($$$1 \le x_i, y_i \le N, x_i \neq y_i, 1 \le c_i \le M$$$), representing a street from $$$x_i$$$ to $$$y_i$$$ with a congestion value of $$$c_i$$$.
Then, one line follows containing the number $$$Q$$$ ($$$1 \le Q \le 100\,000$$$), the number of queries.
Then, $$$Q$$$ lines follow, each containing $$$3$$$ integers, $$$u_i, v_i, l_i$$$ ($$$1 \le u_i, v_i \le N, u_i \neq v_i, 1 \le l_i \le N$$$), representing a query for the minimum possible discomfort level of a tour that starts at $$$u_i$$$, ends at $$$v_i$$$, and has a luminosity level of at least $$$l_i$$$.
There will be $$$Q$$$ lines displayed, each containing a single number, with the $$$i$$$-th one representing the answer to the $$$i$$$-th query.
6 91 3 41 5 81 6 52 5 32 6 33 4 23 5 65 6 94 6 265 6 45 6 35 6 22 4 23 6 33 6 2
9 6 3 3 5 2
Train filled to the brim with American tourists lining up from Căpâlnița to visit the magical city of Mizil.