n = gets.to_i
n.times do
    b = Array.new
    while b.length < 9
        b += gets.split.map{|e| e.to_i(16)}
    end
    key = 0
    32.times do |i|
        s = 0
        8.times do |k|
            s += b[k]
        end
        if (s & (1 << i) != b[8] & (1 << i))
            key |= 1 << i
        end
        9.times do |j|
            b[j] ^= (key & 1 << i)
        end
    end
    puts key.to_s(16)
end