시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
4 초 512 MB 0 0 0 0.000%

## 문제

Flatland has $n$ cities, connected by $m$ one-directional roads.

Tourist company plans to develop a scenic cyclic tour along the roads of Flatland. This tour must start and finish at the same city, visiting some intermediate cities and traveling along some of the roads in their direction. The tour can visit some city multiple times, but it may not use the same road more than once.

Each road is characterized by the type of its landscape, which is the number from $1$ to $m$. To make the tour really magnificent, every two adjacent roads in the tour must have different landscape types. This also should be true for the first and the last road in the tour, so that you start to travel from any city of the tour.

Help the company to find the tour satisfying these conditions, or report that no such tour exists.

## 입력

Input contains multiple test cases. First line contains integer $T$ ($1 \le T \le 10^5$) --- the number of test cases.

First line of each test case's description contains two integers  $n$ and $m$ ($2 \le n, m \le 2 \cdot 10^5$) --- number of cities and roads. Each of next $m$ lines contain three integers $u_i$ $v_i$ $c_i$, meaning that $i$-th road starts at city $u_i$, ends at city $v_i$ and has landscape type $c_i$ ($1 \le u_i, v_i \le n$, $1 \le c_i \le m$, $u_i \neq v_i$).

Sum of all $n$ in all test cases does not exceed $2 \cdot 10^5$. Sum of all $m$ in all test cases does not exceed $2 \cdot 10^5$.

## 출력

Output the answer of each test case.

If the desired tour does not exist, output the only number <<$-1$>>. Otherwise, print number k $2 \le k \le m$ --- the length of the tour. In next line print $k$ numbers $e_1, e_2, \ldots, e_k$ --- numbers of roads in the tour. All numbers $e_i$ must be different. If there are multiple possible tours, output any of them.

3
5 8
1 4 1
2 4 1
4 5 2
3 2 2
5 3 1
3 2 3
5 2 2
2 1 3
4 5
1 2 2
2 3 1
2 4 4
4 1 2
3 1 2
2 3
1 2 1
1 2 2
2 1 1

4
3 5 6 2
-1
2
2 3