#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

class Coor{
       public :
        ll x;
        ll y;
};

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int test;
    cin >> test;
    while(test--)
    {
           ll n;
           cin >> n;
           vector<ll> a(n);
           vector<ll> v(n);
           for(int i=0;i<n;i++) cin >> a[i];
           
           for(int i=1;i<n;i++){
                  if( (a[i] & a[i-1]) == a[i-1]){
                         v[i] = 0;
                  }
                  else{
                         ll current = (a[i] | a[i-1]);
                         v[i] = a[i]-current;
                         a[i] = current;
                  }
           }
           
           for(int i=0;i<n;i++){
                  cout << abs(v[i]) << " ";
           }
           cout << endl;
    }
}
