#include <cstdio>
#include <algorithm>
#include <vector>

int testcase() {
  unsigned N[8], C;
  for (int i=0; i<8; ++i)
    scanf("%x", &N[i]);

  scanf("%x", &C);

  unsigned K=0;
  for (int i=0; i<32; ++i) {
    unsigned cur=0;
    for (int j=0; j<8; ++j) {
      cur += N[j];
    }

    if ((cur>>i & 1) == (C>>i & 1)) continue;
    
    K |= 1u << i;
    for (int j=0; j<8; ++j) {
      N[j] ^= 1u << i;
    }
    C ^= 1u << i;
  }

  printf("%x\n", K);
  return 0;
}

int main() {
  int S;
  scanf("%d", &S);

  for (int i=0; i<S; ++i)
    testcase();

  return 0;
}