#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n; cin >> n;
    vector<int> x(n), ans(n);
    for(int &z : x) cin >> z;
    for(int i = 1; i < n; i++) {
        int c = x[i], lc = x[i-1];
        int y = 0, j = 0;
        while(c > 0 || lc > 0) {
            int b, lb;
            b = c % 2;
            lb = lc % 2;
            if(b != lb && lb == 1) {
                y += (1 << j);
            }
            c /= 2, lc /= 2;
            j++;
        }
        x[i] ^= y;
        ans[i] = y;
    }
    for(int i : ans) cout << i << ' ';
    cout << endl;
}

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