Greedy Farmers

No attempts yetTime limit1sMemory limit128 MB

Problem

The countries of Byteland have decided to unite and form the Union of Byte Countries. One of its first policies is a system of direct agricultural subsidies: every farmer is given a natural number describing the size of the farm they own, and this number determines the subsidy they receive.

To reduce inequality, the parliament decided to pay the most to farmers holding the smallest numbers, counting from 00. Because each farmer would then simply claim the value 00, one rule was added: each farmer must be assigned the smallest natural number that differs from every number assigned to the farmers they employ.

It turns out that for some configurations such an assignment cannot be produced uniquely, or cannot be produced at all. For those situations an extra value, infinity, is used. A farmer XX may be assigned infinity when XX employs some farmer YY who is also assigned infinity, and none of YY's own employees was assigned the finite number that XX would otherwise want to take. The government wants the final assignment to contain as many infinities as possible, and the assignment satisfying this is unique.

Write a program that computes this assignment. For a farmer whose value is infinity, output 1-1.

Input

The first line contains an integer tt (1t1001 \le t \le 100) — the number of test cases. The test cases follow.

Each test case begins with a line containing two integers nn and mm (1n1001 \le n \le 100, 0m<100000 \le m < 10000) — the number of farmers and the number of employment relations between them. The farmers are numbered from 11 to nn.

Each of the next mm lines contains two integers aa and bb (1a,bn1 \le a, b \le n), meaning that farmer aa employs farmer bb.

Output

For each test case output nn lines. The ii-th of these lines must contain the value assigned to farmer ii. If that value is infinity, output 1-1 instead.