Given a graph with $$$N$$$ vertices and $$$M$$$ unordered edges. Each edge $$$i$$$ has a passing rating of $$$W_i$$$ and connects vertices $$$U_i$$$ and $$$V_i$$$.
Bob is allowed to move from one vertex to another using edges. Bob can use the $$$i$$$-th edge if and only if his rating is greater than or equal to $$$W_i$$$. He can use the same edge and visit the same vertex as many times as he wants.
Whenever Bob is located at vertex $$$x$$$, he has two options for gaining a new rating:
Bob now has $$$Q$$$ queries. For each query $$$i$$$, answer the following question:
Print $$$-1$$$ if he cannot reach vertex $$$T_i$$$ even with an infinite number of coins.
It is guaranteed that the sum of $$$N$$$ across all test cases does not exceed $$$5 \cdot 10^5$$$.
It is guaranteed that the sum of $$$M$$$ across all test cases does not exceed $$$5 \cdot 10^5$$$.
It is guaranteed that the sum of $$$Q$$$ across all test cases does not exceed $$$5 \cdot 10^5$$$.
For each test case, print $$$Q$$$ lines, each consisting of one integer, the answer for that query.
15 5 45 2 4 3 101 2 3 4 53 3 101 2 53 4 71 3 132 5 214 5 32 2 41 4 25 2 10
11 0 4 5
| Name |
|---|


