A sequence of non-negative integers a_1, a_2, ..., a_n is called growing if for all i from 1 to n - 1 all ones (of binary representation) in a_i are in the places of ones (of binary representation) in a_{i + 1} (in other words, a_i \:\&\: a_{i + 1} = a_i, where \& denotes [bitwise AND](http://tiny.cc/xpy9uz)). If n = 1 then the sequence is considered growing as well.

For example, the following four sequences are growing: 

  * [2, 3, 15, 175] — in binary it's [10_2, 11_2, 1111_2, 10101111_2]; 
  * [5] — in binary it's [101_2]; 
  * [1, 3, 7, 15] — in binary it's [1_2, 11_2, 111_2, 1111_2]; 
  * [0, 0, 0] — in binary it's [0_2, 0_2, 0_2]. 



The following three sequences are non-growing: 

  * [3, 4, 5] — in binary it's [11_2, 100_2, 101_2]; 
  * [5, 4, 3] — in binary it's [101_2, 100_2, 011_2]; 
  * [1, 2, 4, 8] — in binary it's [0001_2, 0010_2, 0100_2, 1000_2]. 



Consider two sequences of non-negative integers x_1, x_2, ..., x_n and y_1, y_2, ..., y_n. Let's call this pair of sequences co-growing if the sequence x_1 ⊕ y_1, x_2 ⊕ y_2, ..., x_n ⊕ y_n is growing where ⊕ denotes [bitwise XOR](http://tiny.cc/bry9uz).

You are given a sequence of integers x_1, x_2, ..., x_n. Find the lexicographically minimal sequence y_1, y_2, ..., y_n such that sequences x_i and y_i are co-growing.

The sequence a_1, a_2, ..., a_n is lexicographically smaller than the sequence b_1, b_2, ..., b_n if there exists 1 ≤ k ≤ n such that a_i = b_i for any 1 ≤ i < k but a_k < b_k.

Input

The first line contains an integer t (1 ≤ t ≤ 10^4). Then t test cases follow.

The first line of each test case contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — length of the sequence x_i.

The second line contains n integers x_1, x_2, ..., x_n (0 ≤ x_i < 2^{30}) — elements of the sequence x_i.

It is guaranteed that the sum of n overall all test cases doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print n integers y_1, y_2, ..., y_n (0 ≤ y_i < 2^{30}) — lexicographically minimal sequence such that such that it's co-growing with given sequence x_i.

Example

Input


5
4
1 3 7 15
4
1 2 4 8
5
1 2 3 4 5
4
11 13 15 1
1
0


Output


0 0 0 0 
0 1 3 7 
0 1 0 3 2 
0 2 0 14 
0 

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class N731 {
	static PrintWriter out;
	static Scanner sc;
	static ArrayList<Integer>q,w;
	static ArrayList<Integer>adj[];
	static HashSet<Integer>primesH;
	static boolean prime[];
	//static ArrayList<Integer>a;
	static HashSet<Long>tmp;
	static boolean[]v;
	static int[]c,d;
	static int[][]dp;
	static char[][]mp;
	static int A,B,n,m,h,ans;
	static String a,b;
	public static void main(String[]args) throws IOException {
		sc=new Scanner(System.in);
		out=new PrintWriter(System.out);
		//A();
		//B();
	    //C();
	    D();
		// D2();
		//E();
		//F();
		//G();
		out.close();
	}
	  private static void A() throws IOException {
		  	
		  int t=ni();
			while(t-->0) {
				int xa=ni(),ya=ni();
				int xb=ni(),yb=ni();
				int xf=ni(),yf=ni();
				int ans=Math.abs(xa-xb)+Math.abs(ya-yb);
				if(xa==xb&&xb==xf&&inbet(yf,ya,yb)||ya==yb&&yb==yf&&inbet(xf,xa,xb)) {
					ans+=2;
				}
				out.println(ans);
			}
	   }
		private static boolean inbet(int xf, int xa, int xb) {
		return (xf>xa&&xf<xb)|| (xf>xb&&xf<xa);
	}
		static void B() throws IOException {
			int t=ni();
			a:while(t-->0) {
				String s=ns();
				char cur=(char)('a'+s.length()-1);
				int ptr1=0,ptr2=s.length()-1;
				while(ptr1<=ptr2) {
					if(s.charAt(ptr1)==cur) {
						ptr1++;
						cur--;
					}else if(s.charAt(ptr2)==cur) {
						ptr2--;
						cur--;
					}else {
						ol("no");
						continue a;
					}
				}
				ol("yes");
				
			}
		}
		public static int getMoreEq(int i,Long[]a,long k) {
			int st=i+1,end=a.length-1;
			if(a[st]>=k)return st;
			if(a[end]<k)return -1;
			while(end-st>1) {
				int mid=(end+st)/2;//remove 1 maybe?
				if(a[mid]>=k)
					end=mid;
				else
					st=mid;
			}
			return end;

		}
		public static int getLessEq(int i,Long[]a,long k) {
			int st=i+1,end=a.length-1;
			if(a[end]<=k)return end;
			if(a[st]>k)return -1;
			while(end-st>1) {
				int mid=(end+st)/2;//remove 1 maybe?
			    if(a[mid]<=k)
					st=mid;
				else
					end=mid;
			}
			return st;
		}
		static void C() throws IOException{
			 int t=ni();
			 a:while(t-->0) {
				 int k=ni(),n=ni(),m=ni();
				 int[]a=nai(n);
				 int[]b=nai(m);
				 ArrayList<Integer>ans=new ArrayList<Integer>();
				 int pt1=0,pt2=0;
				 for(;pt1<n||pt2<m;) {
					 while(pt1<n&&a[pt1]==0) {
						 ans.add(0);
						 k++;
						 pt1++;
					 }
					 while(pt2<m&&b[pt2]==0) {
						 ans.add(0);
						 k++;
						 pt2++;
					 }
					 if(pt1==n&&pt2==m)break;
					 if(pt1<n&&a[pt1]<=k) {
						 ans.add(a[pt1]);
						 pt1++;
					 }else if(pt2<m&&b[pt2]<=k) {
						 ans.add(b[pt2]);
						 pt2++;
					 }else {
						 ol(-1);
						 continue a;
					 }
				 }
				 for(int x:ans) {
					 out.print(x+" ");
				 }
				 ol("");
			 }
		}
		static ArrayList<Integer>primes;
		static void sieve(int N)
		{
			primes = new ArrayList<Integer>();
			boolean[] isComposite = new boolean[N];
			for(int i = 2; i < N; ++i)
				if(!isComposite[i])
				{
					primes.add(i);
					if(1l*i*i<N) {
					for(int j = i * i; j < N; j += i)
						isComposite[j] = true;
					}
				}
		}
		static int gcd (int a, int b) {
		    return b==0?a:gcd (b, a % b);
		}
		static void D() throws IOException {
			int t=ni();
			//sieve(40000);
			while(t-->0) {
				int n=ni();
				int[]a=nai(n);
				int[]ans=new int[n];
				for(int i=1;i<n;i++) {
					int cur=a[i],prv=a[i-1];
					int chng=0;
					for(int j=0;j<31;j++) {
						if((prv&(1<<j))!=0 &&(cur&(1<<j))==0) {
							chng|=(1<<j);
						}
					}
					ans[i]=chng;
					a[i]^=chng;
				}
				for(int i=0;i<n;i++) {
					out.print(ans[i]+" ");
				}
				ol("");
			}
			
		}
	private static int diff(int n, int g) {
			int idx=0,p=primes.get(0),tot=0;
			while(1l*p*p<=n) {
				int n1=0,n2=0;
				while(n%p==0) {
					n/=p;
					n1++;
				}
				while(g%p==0) {
					g/=p;
					n2++;
				}
				tot+=n1-n2;
				p=primes.get(++idx);
			}
			if(n!=g)tot++;
			return tot;
		}
	private static int fact(int n) {
			int idx=0,p=primes.get(0),tot=0;
			while(1l*p*p<=n) {
				while(n%p==0) {
					n/=p;tot++;
				}
				p=primes.get(++idx);
			}
			if(n!=1)tot++;
			return tot;
		}
	static void E() throws IOException {
		int t=ni();
		//sieve(40000);
		while(t-->0) {
			
		}
		
	}
	static void F() throws IOException {
		int t=ni();
		while(t-->0) {
			
		}
	}
	static void G() throws IOException {
		int t=ni();
		while(t-->0) {
			
		}
	}
	static long [][]d1,d2,map;
	static long W;
	static int []dx=new int[] {0,1,-1,0};
	static int []dy=new int[] {1,0,0,-1};

	private static void bfs(int i, int j,long[][]d) {
		d[i][j]=1;
		int[]q=new int[2*n*m];
		int e=0,s=0;
		q[e++]=i;q[e++]=j;
		while(s<e) {
			int x=q[s++],y=q[s++];
			for(int a=0;a<4;a++) {
				int nx=x+dx[a],ny=y+dy[a];
				if(nx>=0&&nx<n&&ny>=0&&ny<m&&d[nx][ny]==0&&map[nx][ny]!=-1) {
					q[e++]=nx;q[e++]=ny;
					d[nx][ny]=d[x][y]+1;
				}
			}
		}
		for(int a=0;a<d.length;a++)
			for(int b=0;b<d[0].length;b++)
				d[a][b]--;
		
	}
	static int ni() throws IOException {
		return sc.nextInt();
	}
	static double nd() throws IOException {
		return sc.nextDouble();
	}
	static long nl() throws IOException {
		return  sc.nextLong();
	}
	static String ns() throws IOException {
		return sc.next();
	}
	static int[] nai(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		return a;
	}
	static long[] nal(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		return a;
	}
	static int[][] nmi(int n,int m) throws IOException{
		int[][]a=new int[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextInt();
			}
		}
		return a;
	}

	static long[][] nml(int n,int m) throws IOException{
		long[][]a=new long[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextLong();
			}
		}
		return a;
	}
	static void o(String x) {
		out.print(x);
	}
	static void ol(String x) {
		out.println(x);
	}
	static void ol(int x) {
		out.println(x);
	}
	static void disp1(int []a) {
		for(int i=0;i<a.length;i++) {
			out.print(a[i]+" ");
		}
		out.println();
	}

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		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 boolean hasNext() {return st.hasMoreTokens();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
			
		public boolean ready() throws IOException {return br.ready(); }
		

	}
}
