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

signed main() {
    int t = 1;
    cin>>t;
    while(t--) {
        int n; cin>>n;
        vector<int>v(n);
        for(auto &z : v) cin>>z;
        int x = v[0];
        cout << "0 ";
        for(int i = 1 ; i < n ; i++) {
            int y=0;
            for(int j = 0 ; j < 32 ; j++) {
                if((x&(1<<j))) {
                    if(!(v[i]&(1<<j))) {
                        y|=(1<<j);
                    }
                }
            }
            cout << y << " ";
            x=v[i]^y;
        }
        cout << "\n";
    }
}
