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.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Map;
  import java.util.Map.Entry;
  
  //import Number_theory.pair;
  
  import java.util.PriorityQueue;
  import java.util.Queue;
  import java.util.Stack;
  import java.util.StringTokenizer;
  import java.util.TreeMap;
  import java.util.TreeSet;
  
  //import graph_representation.edge;
  public class hacker49 {
  	public static int r1=0;
  	static class FastReader 
      { 
          BufferedReader br; 
          StringTokenizer st; 
    
          public FastReader() 
          { 
              br = new BufferedReader(new
                       InputStreamReader(System.in)); 
          } 
    
          String next() 
          { 
              while (st == null || !st.hasMoreElements()) 
              { 
                  try
                  { 
                      st = new StringTokenizer(br.readLine()); 
                  } 
                  catch (IOException  e) 
                  { 
                      e.printStackTrace(); 
                  } 
              } 
              return st.nextToken(); 
          } 
    
          int nextInt() 
          { 
              return Integer.parseInt(next()); 
          } 
    
          long nextLong() 
          { 
              return Long.parseLong(next()); 
          } 
    
          double nextDouble() 
          { 
              return Double.parseDouble(next()); 
          } 
    
          String nextLine() 
          { 
              String str = ""; 
              try
              { 
                  str = br.readLine(); 
              } 
              catch (IOException e) 
              { 
                  e.printStackTrace(); 
              } 
              return str; 
          } 
      } 
  //static 	ArrayList<Integer>[] f=new ArrayList[200001];
  static 	int[] deg=new int[100001];
  static class y{
  	private int a;
  	private int b;
  	y(int a,int b) {
  		this.a=a;
  		this.b=b;
  	}
  }
  	static HashMap<Long,Integer> e=new HashMap<>();
  	public static void main(String[] args) {
  		OutputStream outputStream =System.out;
  	    PrintWriter out =new PrintWriter(outputStream);
  		FastReader s=new FastReader();
  int t =s.nextInt();
  while(t>0) {
  	int n=s.nextInt();
  	int[] a=new int[n];
  	for(int i=0;i<n;i++) {
  		a[i]=s.nextInt();
  	}
  		if(a[n-1]==0) {
  			for(int i=0;i<=n;i++) {
  				out.print((i+1)+" ");
  			}
  			out.println();
  		}else {
  			int j=-1;
  			for(int i=n-1;i>=0;i--) {
  		if(a[i]==0) {
  			j=i;
  			break;
  		}
  			}
  			if(j==-1) {
  		out.print((n+1)+" ");
  			for(int i=1;i<=n;i++) {
  				out.print(i+" ");
  			}
  			}
  			else {
  				for(int i=0;i<=j;i++) {
  					out.print((i+1)+" ");
  				}
  				out.print((n+1)+" ");
  				for(int i=j+1;i<n;i++) {
  					out.print((i+1)+" ");
  				}
  				out.println();
  			}
  			
  		}
  	
  	
  			
  	t--;
  }
  
  
  out.close();
  	}
  	static  class pair7{
  		private String str;
  		private int b;
  		pair7(String str,int b){
  			this.str=str;
  			this.b=b;
  		}
  	}
  	public static int[] pre=new int[5000001];
  	public static  int[] arr=new int[5000001];
  	public static int[] is_prime=new int[5000001];
  	public static ArrayList<Long> primes=new ArrayList<>();
  	public static void sieve() {
  		long maxN=5000000;
  		for(long i=1;i<=maxN;i++) {
  			is_prime[(int) i]=1;
  		}
  		is_prime[0]=0;
  		is_prime[1]=0;
  		for(long i=2;i*i<=maxN;i++) {
  			if(is_prime[(int) i]!=0) {
  //				primes.add((int) i);
  				long c=1;
  				for(long j=i*i;j<=maxN;j+=i) {
  					is_prime[(int) j]++;
  				}
  			}
  		}
  		
  		for(long i=2;i<=maxN;i++) {
  			is_prime[(int) i]=is_prime[(int) (i-1)]+is_prime[(int) i];
  		}
  //		int count=0;
  //		for(long i=1;i<=maxN;i++) {
  //			if(is_prime[(int) i]==1) {
  //				count++;
  //			}
  //			if(is_prime[count]==1) {
  //				arr[(int) i]=1;
  //			}else {
  //				arr[(int)i]=0;
  //			}
  //		}
  	}
  	
  	public static long GCD(long a,long b) {
  		
  		if(b==(long)0) {
  			return a;
  		}
  		return GCD(b , a%b);
  	}
  	static long c=0;
  	public static long res=1;
  	public static void prime_factorization(long n) {
  		for(long i=2;i*i<=n;i++) {
  			if(n%i==0) {
  				long count=0;
  				while(n%i==0) {
  					count++;
  					n/=i;
  				}
  //			prime_pairs.add(new pair(i,count));
  //			res*=(count+1);
  				c+=(count);
  			}
  		}
  		if(n>1) {
  //			prime_pairs.add(new pair(n,1));
  //		res*=2;
  			c+=(1);
  		}
  		
  	}
  	static long ans1=0;
  	static long ans2=1;
  	static long curr=Long.MAX_VALUE;
  	static long count3=0;
  	static long[] val=new long[100001];
  	static HashMap<Long,Long> e5=new HashMap<>();
  	static int[] visited=new int[100001];
  	static ArrayList<Integer> r2=new ArrayList<>();
  	static ArrayList<Integer> SCC=new ArrayList<>();
  	public static void kosadfs(int node) {
  		visited[node]=1;
  		SCC.add(node);
  		if(curr>val[node]) {
  			count3=1;
  			curr=val[node];
  		}else if(curr==val[node]){
  			count3++;
  		}
  	
  		for(int i=0;i<f1[node].size();i++) {
  			if(visited[(int)f1[node].get(i)]==0) {
  				kosadfs((int)f1[node].get(i));
  			}
  		}
  	}
  	public static void kosarajus_algo(int n) {
  		for(int i=1;i<=n;i++) {
  			if(visited[i]==0) {
  				time(i);
  			}
  		}
  //		time(1);
  		for(int i=1;i<=n;i++) {
  			visited[i]=0;
  		}
  		for(int i=n-1;i>=0;i--) {
  			if(visited[r2.get(i)]==0) {
  				SCC.clear();
  				curr=Long.MAX_VALUE;
  				count3=0;
  				kosadfs(r2.get(i));
  				ans1+=curr;
  //				count3=0;
  				ans2=(ans2*count3)%mod;
  				
  			}
  		}
  	}
  	public static void time(int v) {
  		visited[v]=1;
  		for(int i=0;i<f[v].size();i++) {
  			if(visited[(int)f[v].get(i)]==0) {
  				time((int)f[v].get(i));
  			}
  		}
  		r2.add(v);
  	}
  
  
  
  
  
  	public static int upper_bound(long[] a ,long x,  int g,int n ) {
  		int l=g;
  		int r=n;
  		while(r>l+1) {
  			int mid=(l+r)/2;
  			if(a[mid]>=x) {
  				r=mid;
  			}else {
  				l=mid;
  			}
  		}
  		return r;
  				
  	}
  
  //	
  //	
  	public static int lower_bound(long[] b,long x,int g,int n) {
  		int l=g;
  		int r=n;
  		while(r>l+1) {
  			int mid=(l+r)/2;
  			if(b[mid]<=x) {
  				l=mid;
  			}else {
  				r=mid;
  			}
  		}
  		return l;
  				
  	}
  	
  
  	static int[] vis1=new int[100001];
  	static long count=0;
  	static void dfs(int node) {
  		vis1[node]=1;
  		count++;
  		for(int i=0;i<f[node].size();i++) {
  			if(vis1[f[node].get(i)]==0)
  			dfs(f[node].get(i));
  		}
  		
  	}
  	static ArrayList<Integer>[] f=new ArrayList[100001];
  	static ArrayList<Integer>[] f1=new ArrayList[100001];
  	public static long binary_exponentiation_1(long a,long n) {
  		long res=1;
  		while(n>0) {
  			if(n%2!=0) {
  				res=((res)%(1000000007) * (a)%(1000000007))%(1000000007);
  				n--;
  				
  			}else {
  				a=((a)%(1000000007) *(a)%(1000000007))%(1000000007);
  				n/=2;
  			}
  		}
  		return (res)%(1000000007);
  		
  	}
  	public static long im(long a) {
  		return binary_exponentiation_1(a,mod-2)%mod;
  	}
  	public static long[] fac=new long[10000001];
  	public static void ff() {
  		fac[0]=1;
  		fac[1]=1;
  		for(int i=2;i<=200000;i++) {
  			fac[i]=(fac[i-1]*i)%(mod);
  		}
  	}
  	static int l=1;
  	static int r=1;
  	static int[][] vis=new int[301][301];
  	static boolean isvalid(int x,int y,int n,int m) {
  		if(x>=1 && x<=n && y>=1 && y<=m) {
  			return true;
  		}
  	return false;
  	}
  static void dfs(int n,int m,int count,int g) {
  System.out.print(l+" "+r+" ");
  vis[l][r]=1;
  if(count==g) {
  	return;
  }
  if(isvalid(l,r+1,n,m) && vis[l][r+1]==0) {
  	r++;
  	dfs(n,m,count+1,g);
  	
  }else if(isvalid(l,r-1,n,m) && vis[l][r-1]==0) {
  	r--;
  	dfs(n,m,count+1,g);
  //	l++;
  }else {
  	l++;
  	dfs(n,m,count+1,g);
  //	l--;
  }
  
  }
  	public static long be(long a,long n) {
  		long res=1;
  		while(n>0) {
  			if(n%2!=0) {
  //				res=((res)%(1000000007) * (a)%(1000000007))%(1000000007);
  				res=res*a;
  				n--;
  			}else {
  //				a=((a)%(1000000007) *(a)%(1000000007))%(1000000007);
  				a=a*a;
  				n/=2;
  			}
  		}
  //		return (res)%(1000000007);
  		return res;
  	}
  //	
  	static class pair2 implements Comparable<pair2>{
  //		private int a;
  //		private int b;
  		private long a;
  		private long  b;
  		pair2(long a,long b){
  			this.a=a;
  			this.b=b;
  //			this.c=c;
  		}
  		public int compareTo(pair2 o) {
  //			
  //			return Long.compare(o.c,this.c);
  		return Long.compare(this.a, o.a);			
  		}
  		
  	}
  	
  
  
  		
  	
  	
  	
  	public static long[] merge_sort(long[] A, int start, int end) {
  		if (end > start) {
  			int mid = (end + start) / 2;
  			long[] v = merge_sort(A, start, mid);
  			long[] o = merge_sort(A, mid + 1, end);
  			return (merge(v, o));
  		} else {
  			long[] y = new long[1];
  			y[0] = A[start];
  			return y;
  		}
  	}
  	public static long[] merge(long a[], long b[]) {
  //		int count=0;
  		long[] temp = new long[a.length + b.length];
  		int m = a.length;
  		int n = b.length;
  		int i = 0;
  		int j = 0;
  		int c = 0;
  		while (i < m && j < n) {
  			if (a[i] < b[j]) {
  				temp[c++] = a[i++];
  			
  			} else {
  				temp[c++] = b[j++];
  			}
  		}
  		while (i < m) {
  			temp[c++] = a[i++];
  		}
  		while (j < n) {
  			temp[c++] = b[j++];
  		}
  		return temp;
  	}
  	
  	public static int[] merge_sort1(int[] A, int start, int end) {
  		if (end > start) {
  			int mid = (end + start) / 2;
  			int[] v = merge_sort1(A, start, mid);
  			int[] o = merge_sort1(A, mid + 1, end);
  			return (merge1(v, o));
  		} else {
  			int[] y = new int[1];
  			y[0] = A[start];
  			return y;
  		}
  	}
  	public static int[] merge1(int a[], int b[]) {
  //		int count=0;
  		int[] temp = new int[a.length + b.length];
  		int m = a.length;
  		int n = b.length;
  		int i = 0;
  		int j = 0;
  		int c = 0;
  		while (i < m && j < n) {
  			if (a[i] < b[j]) {
  				temp[c++] = a[i++];
  			
  			} else {
  				temp[c++] = b[j++];
  			}
  		}
  		while (i < m) {
  			temp[c++] = a[i++];
  		}
  		while (j < n) {
  			temp[c++] = b[j++];
  		}
  		return temp;
  	}
  	
  	static long mod=1000000007;
  	
  
  
  
  
  //	for(int i=2;i<=100000;i++) {
  		
  	
  }