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

#define ll long long
#define int long long


void problem_solver() {
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i=0; i<n; i++)  cin >> arr[i];
	vector<int> ans;
	ans.push_back(0);
	for(int i=1; i<n; i++) {
		int val = arr[i] & arr[i-1];
		val ^= arr[i-1];
		ans.push_back(val);
		arr[i] += val;
	}
	for(int i : ans)  cout << i << " ";
}

int32_t main() {
	int t = 1;
	cin >> t;
	while(t--) {
		problem_solver();
		cout << "\n";
	}
}