#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define ll long long

using namespace std;

int main() {
    ll qua;
    cin >> qua;
    for (int i = 0; i < qua; ++i) {
        ll n;
        cin >> n;
        vector<int> vec(n);
        for (int j = 0; j < n; ++j) {
            cin >> vec[j];
        }
        cout << 0 << ' ';
        for (int j = 1; j < n; ++j) {
            ll r = (vec[j] | vec[j - 1]) - vec[j];
            cout << r << ' ';
            vec[j] += r;
        }
        cout << '\n';
    }
    return 0;
}
