#include <cstdio>

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	while(n--){
		unsigned int c[9];
		for(int i = 0; i < 9; ++i){ scanf("%x", c + i); }
		unsigned int k = 0;
		for(int i = 0; i < 32; ++i){
			const unsigned int m = (1u << i);
			unsigned int sum = 0;
			for(int j = 0; j < 8; ++j){ sum += c[j] ^ k; }
			if((sum & m) != (c[8] & m)){ k |= m; }
		}
		printf("%x\n", k);
	}
	return 0;
}