#pragma comment(linker,"/STACK:5000000000")
#define _CRT_NO_VA_START_VALIDATION
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#pragma once

#define vec vector
#define len length
#define sz size
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define dbg(x) std::cerr << (#x) << "\t\t=\t\t" << (x) << '\n';

#define fori(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define forI(i,n,m) for(int (i) = (n); (i) < (m); ++(i))
#define Fori(i,n) for(int (i) = (n)-1; (i) >= 0; --(i))
#define fora(i,a) for(auto (i) = (a).begin(); (i) != (a).end(); ++(i))

using vi = vec<int>;
using vvi = vec<vi>;
using ll = long long;
using vl = vec<ll>;
using vvl = vec<vl>;
using ld = long double;

string sep = " ";

template<class T>
istream& operator>>(istream &in, vec<T> &a) {
  for(T &i : a)
    in >> i;
  return in;
}

template<class T, class U>
istream& operator>>(istream &in, pair<T, U> &p) {
  in >> p.ff >> p.ss;
  return in;
}

template<class T>
ostream& operator<<(ostream &out, vec<T> a) {
  for(T &i : a)
    out << i << sep;
  return out;
}

template<class T, class U>
ostream& operator<<(ostream &out, pair<T, U> &p) {
  out << p.ff << sep << p.ss;
  return out;
}

template<class T>
T gcd(T a, T b) {
  return (!b ? a : gcd(b, a%b));
}

void solve(void) {

  int n; cin >> n;
  vi a(n); cin >> a;
  vi b(n);
  forI(i,1,n) {
    b[i] = (a[i]|a[i-1]) - a[i];
    a[i] = a[i]|a[i-1];
  }
  cout << b << '\n';

  return;
}

signed main(void) {
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); cout << setprecision(10) << fixed;
#ifdef YuriAndropov
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
#endif
  int tt; cin >> tt; while(tt--) solve();

  

  fprintf(stderr, "Time elapsed: %dms\n", 1000*clock() / CLOCKS_PER_SEC);
  return 0;
} 