### main

n = gets.to_i

n.times do
  ns = []
  while ns.length < 9
    ns += gets.split.map{|s| s.hex}
  end

  cs = ns.pop
  #p [ns, cs]

  key = 0
  bmask = 1
  b = 1

  for i in (0..31)
    key0 = key
    key1 = key | b

    for k in [key0, key1]
      csk = (cs ^ k) & bmask
      sum = ns.map{|ni| ni ^ k}.inject(:+) & bmask
      if sum == csk
        key = k
        break
      end
    end

    bmask = ((bmask << 1) | 1)
    b <<= 1
  end

  puts "%x" % key
end