#include<bits/stdc++.h>
using namespace std;
//BitWise Operators
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)
#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define F first
#define S second
typedef vector<pli> vpli;
#define INF 1000000007
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define tests int t; cin>>t; while(t--)
#define take(a,b,c) for(b=0;b<c;b++) cin>>a[b];
typedef long long ll;
vector<int> ans, adj[200007];
bool vis[200007];
int inputorder[200007], relorder[200007];
bool cmp(int a, int b) {
    return relorder[a] < relorder[b];
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    tests
    {
        int n; cin >> n;
        vector<int>v(n);
        for (int &x : v)
            cin >> x;
        vector<int> res;
        res.pb(0);
        for (int i = 1; i < n; i++)
        {
            int temp = 0;
            bitset<32> t;
            bitset<32> t_1;
            for (int j = 0; j < 32; j++)
            {
                if (bitset<32>(v[i - 1])[j] == 1 && bitset<32>(v[i])[j] == 0)
                {
                    setBit(temp, j);
                }
            }
            v[i] = v[i] ^ temp;
            res.pb(temp);


        }
        for (int x : res)
            cout << x << " ";
        cout << endl;
    }
}