#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define INP(arr,n) for(int a=0;a<n;a++)cin>>arr[a]
#define OTP(arr,n) for(int a=0;a<n;a++)cout<<arr[a]<<" "
#define ll long long int
#define pb(v,a) v.push_back(a)
int main() {
IOS;int t = 0;cin >> t;
while (t--) {
    ll n = 0;cin >> n;
    ll arr[n];INP(arr,n);
    cout << "0 ";
    for (ll a = 1;a < n;a++) {
        ll x = 0,y = 1;
        bitset <64> bs(arr[a - 1]);
        bitset <64> bs2(arr[a]);
        for (int b = 0;b < 64;b++,y *= 2)
            bs2[b] == 0 && bs[b] == 1 ? x += y,arr[a] += y: x = x;
        cout << x << " ";
    }
    cout << "\n";
}
}