/**
 * @(#)cloudnet.java
 *
 *
 * @author 
 * @version 1.00 2012/7/18
 */

import java.io.*;
import java.util.Scanner;

public class cloudnet {

	public static void main(String[] args) throws IOException 
	{
    	// Variable declarations
    	int numCases, numSwitches, i, j, leftIndex, rightIndex, midIndex;
    	
    	// Set up the scanner and get the number of cases
    	Scanner input = new Scanner(new File("cloudnet.in"));
    	numCases = input.nextInt();
    	
    	// Process each case
    	for(i=0; i<numCases; i++)
    	{
    		// Get number and configuration of switches
    		// Also convert it to array format
    		numSwitches = input.nextInt();
    		int[] panel = new int[numSwitches];
    		for(j=0; j<numSwitches; j++)
    			panel[j] = Integer.parseInt(input.next()); 			
    	
    		// Flip the switches according to the rules
    		for(midIndex=numSwitches-1; midIndex>-1; midIndex--)
    		{
    			// Assume we are considering one of the middle switches
    			leftIndex = midIndex-1;
    			rightIndex = midIndex+1;
    			
    			// Make adjustments for the cases where we are at the end of a row
    			if(midIndex==numSwitches-1)
    				rightIndex = 0;
    			else if(midIndex==0)
    				leftIndex = numSwitches-1;
    				
    			// Actually flip the switches
    			// 1. Case where all switches are flipped up or all are flipped down
    			if(panel[midIndex]==panel[leftIndex] && panel[midIndex]==panel[rightIndex])
    			{
    				panel[midIndex] = flip(panel[midIndex]);
    			}
    			// 2. Case where right switch is different than the other two
    			else if(panel[midIndex]==panel[leftIndex]){
    				panel[leftIndex] = flip(panel[leftIndex]);
    			}
    			// 3. Case where left switch is different than the other two
    			else if(panel[midIndex]==panel[rightIndex]){
    				panel[midIndex] = flip(panel[midIndex]);
    			}
    			// 4. Case where the middle switch is different than the other two
    			else
    			{
    				panel[rightIndex] = flip(panel[rightIndex]);
    				panel[midIndex] = flip(panel[midIndex]);
    				panel[leftIndex] = flip(panel[leftIndex]);
    			}
    		}
    		
    		// Print out the state of the switches after flipping
    		for(j=0; j<numSwitches; j++)
    			System.out.print(panel[j]);
    		System.out.println();
    	} 
    		
    	// Close the scanner for justice
    	input.close();
	}
    
    // Flips the switch from 1 to 0 and vice versa
    static int flip(int s)
    {
    	if(s==1)
    		return 0;
    	else
    		return 1;
    }
    
    
}