//#include <bits/stdc++.h>

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//#define int long long
#define ln '\n'
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define P(p) cout << (p) << endl;
#define S(s) cin << (s);
#define reps(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define rep(i,n) reps(i,0,n)
#define repst(i,a,b) rep(i,s,(n)+1)
#define rept(i,n) rep(i,(n)+1)
#define reprt(i,a,b) for(int (i)=(a); (i)>=(b); --(i))
#define repr(i,n) reprt(i,n,0)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define debug(x) cerr << #x << ": " << x << '\n'
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

typedef unsigned usd;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<unsigned> vus;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const double EPS = 1e-9;
const double PI  = acos(-1.0);

/*********TEMPLATE**********/

int main() {

  int i, j, n, k;
  cin >> n;

  rep(j,n) {
    vus N(9);
    cin >> hex >> N[0] >> N[1] >> N[2] >> N[3] >> N[4] >> N[5] >> N[6] >> N[7] >> N[8];
    usd K = 0;
    rep(m,32) {
      i = 1;
      usd checksum = accumulate(all(N),0) - N.back();
      if ((checksum >> m & 1) != (N.back() >> m & 1)) K |= 1 << m;
      rep(k,9) N[k] ^= K & 1 << m;
    }
    cout << hex << K << endl;
  }

  return 0;
}

