In Flatland, there are cities connected by one-way roads.
A tourist company wants to create a scenic cyclic route using these roads. The route should start and end in the same city, following the roads in their given directions and visiting intermediate cities. While a city can be visited multiple times, no road should be traversed more than once.
Each road has a landscape type, represented by a number from to . For the route to be considered scenic, any two consecutive roads must have different landscape types. This rule also applies to the first and last road of the route, ensuring the journey can begin from any city on the route.
Your task is to help the company find such a route or determine if it's impossible.
The input consists of multiple test cases. The first line contains the integer — the number of test cases (1 \le T \le 10^5).
For each test case, the first line contains two integers and — the number of cities and roads (2 \le n, m \le 2 \cdot 10^5). The next lines each describe a road with three integers u_i, v_i, and c_i — the starting city, the destination city, and the landscape type of the -th road (1 \le u_i, v_i \le n; 1 \le c_i \le m; u_i \ne v_i).
The total sum of across all test cases does not exceed 2 \cdot 10^5. Similarly, the total sum of across all test cases does not exceed 2 \cdot 10^5.
For each test case, output the result.If no suitable route exists, print "-1". If a route is possible, print the integer — the length of the route (2 \le k \le m). On the next line, print integers (e_1, e_2, \ldots, e_k) — the road numbers in the order they appear in the route. All numbers e_i must be distinct. If multiple routes are possible, any valid route can be printed.
Example 1