Contents
Mocha and Hiking solution codeforces

For Solution
Click Here!
The city where Mocha lives in is called Zhijiang. There are n+1n+1 villages and 2n−12n−1 directed roads in this city.
There are two kinds of roads:
 n−1n−1 roads are from village ii to village i+1i+1, for all 1≤i≤n−11≤i≤n−1.
 nn roads can be described by a sequence a1,…,ana1,…,an. If ai=0ai=0, the iith of these roads goes from village ii to village n+1n+1, otherwise it goes from village n+1n+1 to village ii, for all 1≤i≤n1≤i≤n.
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 tt (1≤t≤201≤t≤20) — the number of test cases. Each test case consists of two lines.
The first line of each test case contains a single integer nn (1≤n≤1041≤n≤104) — indicates that the number of villages is n+1n+1.
The second line of each test case contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤10≤ai≤1). If ai=0ai=0, it means that there is a road from village ii to village n+1n+1. If ai=1ai=1, it means that there is a road from village n+1n+1 to village ii.
It is guaranteed that the sum of nn over all test cases does not exceed 104104.
For each test case, print a line with n+1n+1 integers, where the iith number is the iith village they will go through. If the answer doesn’t exist, print −1−1.
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 (1→4→2→3)(1→4→2→3), (1→2→3→4)(1→2→3→4).
In the second test case, the city looks like the following graph:
So all possible answers are (4→1→2→3)(4→1→2→3), (1→2→3→4)(1→2→3→4), (3→4→1→2)(3→4→1→2), (2→3→4→1)(2→3→4→1).

For Solution
Click Here!