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

void solve(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	vector<int> ans;
	ans.push_back(0);
	
	int current = a[0];
	for(int i=1;i<n;i++){
		int cans = (current|a[i])^a[i];
		ans.push_back(cans);
		current = current|a[i];
	}
	
	for(int i=0;i<n;i++){
		cout << ans[i] << " ";
	}
	
	cout << endl;
}

int main(){
	int t=1;
	cin >> t;
	while(t--){
		solve();
	}
}