#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long
#define fi first
#define se second
using namespace std;
const ll mod = 998244353;
const ll M = 1e9+7;

int main(){
    FAST;
    int t;
    cin >> t;
    while(t--){
       int n;
       cin >> n;
       vector<ll>a(n);
       for(auto &i:a)cin>>i;
       int pre = 0;
       for(int i=0;i<n;i++){
            pre |= a[i];
           cout << (pre^a[i]) <<' ';
       }
      cout <<'\n';
    }
    return 0;
}