#include<bits/stdc++.h>

#define ll long long
#define pi pair<int,int>
#define endl "\n";

using namespace std;

void fill_min_time(bool reverse, vector<int> &trains, vector<int> &min_time_required) {

    

}

void run() {
    int n;
    cin>>n;
    vector<int> a(n), ans(n, 0);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }

    for(int i=1;i<n;i++) {

        int ele = a[i-1]^ans[i-1];

        // cout<<ele<<endl;

        if((ele & a[i]) != ele) {
            ans[i] = (ele | a[i]) ^ a[i];
        }
    }

    for(int i=0;i<n;i++) {
        cout<<ans[i]<<" ";
    }
    cout<<endl;

}

void run_t_times() {
    int t;
    cin>>t;
    while(t--) {
        run();
    }
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    run_t_times();
    // run();
    
    return 0;
}