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.util.*;
  	import java.io.*;
  	public class Main {
  		static int c=0;
  		public static void main(String[] args) throws FileNotFoundException,IOException {
  			Scanner s=new Scanner(System.in);
  			PrintWriter pw=new PrintWriter(System.out);
  			
  			
  
  			
  			int t=s.nextInt();
  			while (t-->0)
  			{
  				
  					int n=s.nextInt();
  					HashSet<Integer> to4=new HashSet<>();
  					HashSet<Integer> from4=new HashSet<>();
  					boolean isValid=false;
  					for (int i=1;i<=n;i++)
  					{	
  						int x=s.nextInt();
  						if(i==n && x==0) isValid=true;
  						
  						if (x==0)
  							to4.add(i);
  						else
  							from4.add(i);
  					}
  					
  					if(isValid)
  					{
  						for (int i=1;i<=n+1;i++)
  						{	
  							pw.print(i+" ");
  						}
  						pw.println();
  						continue;
  					}
  					ArrayList<Integer> res=new ArrayList<>();
  					for (int i=1;i<=n;i++)
  					{	
  						res.add(i);
  						if (to4.contains(i) && from4.contains(i+1) && !isValid)
  						{	
  							isValid=true;
  							res.add(n+1);
  							res.add(i+1);
  							i++;
  						}
  							
  					}
  					if (isValid)
  					{
  						for (int x: res)
  							pw.print(x+" ");
  						pw.println();
  						continue;
  					}
  					
  					
  					if (from4.contains(1))
  					{
  						pw.print((n+1)+" ");
  						for (int i=1;i<=n;i++)
  							pw.print(i+" ");
  						pw.println();
  						continue;
  					}
  					
  					pw.println(-1);
  			
  			
  			
  			
  			
  			}
  				
  				
  				
  				
  				
  				
  				
  			
  			
  			
  			
  			
  						
  						
  			
  				
  			
  			
  			
  			
  			
  		
  		pw.flush();
  		
  		}
  
  		public static void shuffle(int []a)
  		{	
  			for (int i=0; i<a.length;i++)
  			{
  				int randIndex=(int)(Math.random()*a.length);
  				int temp=a[i];
  				a[i]=a[randIndex];
  				a[randIndex]=temp;
  			}
  			
  		}
  		
  		
  		
  		
  		
  		}
  //	class Node{
  //		int data;
  //		Node left;
  //		Node right;
  //		public Node(int data)
  //		{
  //			this.data=data;
  //		}
  //	}
  //	class BTree{
  //		Node root;
  //		public void add(int data)
  //		{
  //			Node newNode=new Node(data);
  //			if (root==null)
  //		}
  //	}
  //	 class LinkList {
  //		Node first,last;
  //		static Node pos=null;
  //		static int c=0;
  //		public void insertLast(int data)
  //		{
  //			Node newNode=new Node(data);
  //			
  //			if (last==null)
  //			{
  //				first=last=newNode;
  //			}
  //			else
  //			{
  //				last.next=newNode;
  //				newNode.prev=last;
  //				last=newNode;
  //			}
  //		}
  //		public String toString()
  //		{
  //			Node curr=first;
  //			String res="";
  //			while (curr!=null)
  //			{
  //				res+=curr.data+" ";
  //				curr=curr.next;
  //			}
  //			return res;
  //		}
  //		public void initialisePos(int p)
  //		{	
  //			pos=first;
  //			while (++c!=p)
  //				pos=pos.next;
  //			
  //		}
  //		public void insertLeft(int data)
  //		{	
  //			Node newNode=new Node(data);
  //			if (pos.prev==null)
  //			{
  //				first.prev=newNode;
  //				newNode.next=first;
  //				first=newNode;
  //			}
  //			else
  //			{
  //				
  //				pos.prev.next=newNode;
  //				newNode.prev=pos.prev;
  //				newNode.next=pos;
  //				pos.prev=newNode;
  //				
  //				
  //			}
  //		}
  //		public void insertRight(int data)
  //		{
  //			Node newNode=new Node(data);
  //			if (pos.next==null)
  //			{
  //				last.next=newNode;
  //				newNode.prev=last;
  //				last=newNode;
  //			}
  //			else
  //			{
  //				pos.next.prev=newNode;
  //				newNode.next=pos.next;
  //				newNode.prev=pos;
  //				pos.next=newNode;
  //			}
  //		}
  //	
  //		
  //	
  //	
  //	
  //	}
  
  	class Scanner 
  	{
  		StringTokenizer st;
  		BufferedReader br;
  
  		public Scanner() {
  		br = new BufferedReader(new InputStreamReader(System.in));
  }		
  		public Scanner(String s) throws FileNotFoundException
  		{
  			br =new BufferedReader(new FileReader(s));
  		}
  
  		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
  
  
  		public String next() throws IOException 
  		{
  			while (st == null || !st.hasMoreTokens()) 
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
  
  		public int nextInt() throws IOException {return Integer.parseInt(next());}
  		
  		public long nextLong() throws IOException {return Long.parseLong(next());}
  
  		public String nextLine() throws IOException {return br.readLine();}
  		
  		public double nextDouble() throws IOException
  		{
  			String x = next();
  			StringBuilder sb = new StringBuilder("0");
  			double res = 0, f = 1;
  			boolean dec = false, neg = false;
  			int start = 0;
  			if(x.charAt(0) == '-')
  			{
  				neg = true;
  				start++;
  			}
  			for(int i = start; i < x.length(); i++)
  				if(x.charAt(i) == '.')
  				{
  					res = Long.parseLong(sb.toString());
  					sb = new StringBuilder("0");
  					dec = true;
  				}
  				else
  				{
  					sb.append(x.charAt(i));
  					if(dec)
  						f *= 10;
  				}
  			res += Long.parseLong(sb.toString()) / f;
  			return res * (neg?-1:1);
  		}
  		
  		public boolean ready() throws IOException {return br.ready();}
  
  
  	}
  	
  	