#include <bits/stdc++.h>
using namespace std;

int main()
{
	int t ;
	cin>>t;
	while(t -- ) 
	{
		int n; 
		cin>>n;
		
		int x ;
		cin>>x;
		printf("0 ");
        for(int i = 2;i <= n;i++)
		{
            int y;
            cin>>y;
            printf("%d ",(x | y) ^ y);
            x |= y;
        }
    	cout<<endl;
	}
	return 0 ;
}