description: The city where Mocha lives in is called Zhijiang. There are n+1 villages and 2n-1 directed roads in this city. 
  
  There are two kinds of roads:
  
    * n-1 roads are from village i to village i+1, for all 1≤ i ≤ n-1. 
    * n roads can be described by a sequence a_1,…,a_n. If a_i=0, the i-th of these roads goes from village i to village n+1, otherwise it goes from village n+1 to village i, for all 1≤ 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? 
  
  Input
  
  Each test contains multiple test cases. 
  
  The first line contains a single integer t (1 ≤ 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 n (1 ≤ n ≤ 10^4) — indicates that the number of villages is n+1.
  
  The second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1). If a_i=0, it means that there is a road from village i to village n+1. If a_i=1, it means that there is a road from village n+1 to village i.
  
  It is guaranteed that the sum of n over all test cases does not exceed 10^4.
  
  Output
  
  For each test case, print a line with n+1 integers, where the i-th number is the i-th village they will go through. If the answer doesn't exist, print -1.
  
  If there are multiple correct answers, you can print any one of them.
  
  Example
  
  Input
  
  
  2
  3
  0 1 0
  3
  1 1 0
  
  
  Output
  
  
  1 4 2 3 
  4 1 2 3 
  
  Note
  
  In the first test case, the city looks like the following graph:
  
  <image>
  
  So all possible answers are (1 → 4 → 2 → 3), (1 → 2 → 3 → 4).
  
  In the second test case, the city looks like the following graph:
  
  <image>
  
  So all possible answers are (4 → 1 → 2 → 3), (1 → 2 → 3 → 4), (3 → 4 → 1 → 2), (2 → 3 → 4 → 1).
solution: import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.InputMismatchException;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Map;
  import java.util.Objects;
  import java.util.Set;
  
  /**
   * @author ethan55
   */
  public class Solution {
  
    public static void main(String[] args) {
      TestRunner.run();
    }
  
    public static class TestCase {
  
      static final boolean MULTIPLE = true;
  
      Graph<Integer> g = new Graph<>(true);
      int n;
      int[] prev;
  
      public void solve(InputReader in, OutputWriter out) {
        n = in.nextInt();
        prev = new int[n + 2];
        for (int i = 1; i <= n + 1; i++) {
          g.addNode(i);
        }
        for (int i = 1; i < n; i++) {
          g.addEdge(i, i + 1);
        }
        for (int i = 0; i < n; i++) {
          if (in.nextInt() == 0) {
            g.addEdge(i + 1, n + 1);
          } else {
            g.addEdge(n + 1, i + 1);
          }
        }
  
        for (int i = 1; i <= n + 1; i++) {
          Set<Integer> visted = new HashSet<>();
          visted.add(i);
          int result = search(i, visted);
          if (result != -1) {
            List<Integer> path = new ArrayList<>();
            while (result != i) {
              path.add(result);
              result = prev[result];
            }
            path.add(i);
            Collections.reverse(path);
            out.println(path);
            return;
          }
        }
        out.println(-1);
      }
  
      private int search(int node, Set<Integer> visited) {
        if (visited.size() == n + 1) {
          return node;
        }
  
        for (int n : g.getNeighbors(node)) {
          if (!visited.contains(n)) {
            visited.add(n);
            prev[n] = node;
            int result = search(n, visited);
            visited.remove(n);
            if (result != -1) {
              return result;
            }
          }
        }
        return -1;
      }
    }
  
    public static class TestRunner {
  
      public static void run() {
        InputReader in = new InputReader(System.in);
        try (OutputWriter out = new OutputWriter(System.out)) {
          int testCases = TestCase.MULTIPLE ? in.nextInt() : 1;
          for (int i = 1; i <= testCases; i++) {
            new TestCase().solve(in, out);
          }
        }
      }
  
    }
  
    public static class InputReader {
  
      private final InputStream inputStream;
      private final byte[] inputBuffer = new byte[1024];
      private int bytesRead = 0;
      private int inputBufferIndex = 0;
  
      public InputReader(InputStream inputStream) {
        this.inputStream = inputStream;
      }
  
      private int readByte() {
        if (bytesRead == -1) {
          throw new InputMismatchException();
        }
        if (inputBufferIndex >= bytesRead) {
          inputBufferIndex = 0;
          try {
            bytesRead = inputStream.read(inputBuffer);
          } catch (IOException e) {
            throw new InputMismatchException();
          }
          if (bytesRead <= 0) {
            return -1;
          }
        }
        return inputBuffer[inputBufferIndex++];
      }
  
      public int nextInt() {
        return (int) nextLong();
      }
  
      public long nextLong() {
        long num = 0;
        int b;
        boolean minus = false;
        do {
          b = readByte();
        } while (b != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if (b == '-') {
          minus = true;
          b = readByte();
        }
  
        while (true) {
          if (b >= '0' && b <= '9') {
            num = num * 10 + (b - '0');
          } else {
            return minus ? -num : num;
          }
          b = readByte();
        }
      }
  
    }
  
    public static class OutputWriter implements AutoCloseable {
  
      private static final int BUFFER_SIZE = 1 << 13;
      private final byte[] outputBuffer = new byte[BUFFER_SIZE];
      private final OutputStream outputStream;
      private int outputBufferIndex = 0;
  
      public OutputWriter(OutputStream os) {
        this.outputStream = os;
      }
  
      public OutputWriter println(int x) {
        return writeln(x);
      }
  
      public <T> OutputWriter println(Collection<T> c) {
        return writeln(c);
      }
  
      public void flush() {
        innerFlush();
        try {
          outputStream.flush();
        } catch (IOException e) {
          throw new IllegalStateException("Failed to flush");
        }
      }
  
      private OutputWriter write(byte b) {
        outputBuffer[outputBufferIndex++] = b;
        if (outputBufferIndex == BUFFER_SIZE) {
          innerFlush();
        }
        return this;
      }
  
      private OutputWriter write(char c) {
        return write((byte) c);
      }
  
      private OutputWriter write(String s) {
        s.chars()
            .forEach(
                c -> {
                  outputBuffer[outputBufferIndex++] = (byte) c;
                  if (outputBufferIndex == BUFFER_SIZE) {
                    innerFlush();
                  }
                });
        return this;
      }
  
      private OutputWriter write(int x) {
        if (x == Integer.MIN_VALUE) {
          return write((long) x);
        }
        if (outputBufferIndex + 12 >= BUFFER_SIZE) {
          innerFlush();
        }
        if (x < 0) {
          write((byte) '-');
          x = -x;
        }
        int d = countDigits(x);
        for (int i = outputBufferIndex + d - 1; i >= outputBufferIndex; i--) {
          outputBuffer[i] = (byte) ('0' + x % 10);
          x /= 10;
        }
        outputBufferIndex += d;
        return this;
      }
  
      private static int countDigits(long l) {
        if (l >= 1000000000000000000L) {
          return 19;
        }
        if (l >= 100000000000000000L) {
          return 18;
        }
        if (l >= 10000000000000000L) {
          return 17;
        }
        if (l >= 1000000000000000L) {
          return 16;
        }
        if (l >= 100000000000000L) {
          return 15;
        }
        if (l >= 10000000000000L) {
          return 14;
        }
        if (l >= 1000000000000L) {
          return 13;
        }
        if (l >= 100000000000L) {
          return 12;
        }
        if (l >= 10000000000L) {
          return 11;
        }
        if (l >= 1000000000L) {
          return 10;
        }
        if (l >= 100000000L) {
          return 9;
        }
        if (l >= 10000000L) {
          return 8;
        }
        if (l >= 1000000L) {
          return 7;
        }
        if (l >= 100000L) {
          return 6;
        }
        if (l >= 10000L) {
          return 5;
        }
        if (l >= 1000L) {
          return 4;
        }
        if (l >= 100L) {
          return 3;
        }
        if (l >= 10L) {
          return 2;
        }
        return 1;
      }
  
      private OutputWriter write(long x) {
        if (x == Long.MIN_VALUE) {
          return write("" + x);
        }
        if (outputBufferIndex + 21 >= BUFFER_SIZE) {
          innerFlush();
        }
        if (x < 0) {
          write((byte) '-');
          x = -x;
        }
        int d = countDigits(x);
        for (int i = outputBufferIndex + d - 1; i >= outputBufferIndex; i--) {
          outputBuffer[i] = (byte) ('0' + x % 10);
          x /= 10;
        }
        outputBufferIndex += d;
        return this;
      }
  
      private OutputWriter writeln(int x) {
        return write(x).writeln();
      }
  
      private <T> OutputWriter writeln(Collection<T> c) {
        return write(c).writeln();
      }
  
      private <T> OutputWriter write(Collection<T> xs) {
        boolean first = true;
        for (T x : xs) {
          if (!first) {
            write(' ');
          }
          first = false;
          write(x);
        }
        return this;
      }
  
      private OutputWriter write(Object o) {
        return write(Objects.toString(o));
      }
  
      private OutputWriter writeln() {
        return write((byte) '\n');
      }
  
      private void innerFlush() {
        try {
          outputStream.write(outputBuffer, 0, outputBufferIndex);
          outputBufferIndex = 0;
        } catch (IOException e) {
          throw new IllegalStateException("Failed to inner flush");
        }
      }
  
      @Override
      public void close() {
        flush();
      }
    }
  
    public static class Graph<T> {
  
      private final boolean isDirected;
      private final Map<T, List<T>> nodes = new HashMap<>();
  
      public Graph(boolean isDirected) {
        this.isDirected = isDirected;
      }
  
      public void addNode(T node) {
        nodes.putIfAbsent(node, new LinkedList<>());
      }
  
      public void addEdge(T from, T to) {
        nodes.get(from).add(to);
        if (!isDirected) {
          nodes.get(to).add(from);
        }
      }
  
      public List<T> getNeighbors(T node) {
        return nodes.get(node);
      }
    }
  }