Mocha and Hiking solution codeforces
The city where Mocha lives in is called Zhijiang. There arevillages and directed roads in this city.
There are two kinds of roads:
- roads are from village to village , for all .
- roads can be described by a sequence . If , the -th of these roads goes from village to village , otherwise it goes from village to village , for all .
Mocha plans to go hiking with Taki this weekend. To avoid the trip being boring, they plan to go through every village exactly once. They can start and finish at any villages. Can you help them to draw up a plan?
Each test contains multiple test cases.
The first line contains a single integer( ) — the number of test cases. Each test case consists of two lines.
The first line of each test case contains a single integer( ) — indicates that the number of villages is .
The second line of each test case containsintegers ( ). If , it means that there is a road from village to village . If , it means that there is a road from village to village .
It is guaranteed that the sum ofover all test cases does not exceed .
For each test case, print a line withintegers, where the -th number is the -th village they will go through. If the answer doesn’t exist, print .
If there are multiple correct answers, you can print any one of them.
2 3 0 1 0 3 1 1 0
1 4 2 3 4 1 2 3
In the first test case, the city looks like the following graph:
So all possible answers are, .
In the second test case, the city looks like the following graph:
So all possible answers are, , , .