#include <stdio.h>

int main(void) {
	int dataset_num,cur_data;
	unsigned int chunks[9];
	int i,j;
	int key,sum;
	scanf("%d",&dataset_num);
	for(cur_data=0;cur_data<dataset_num;cur_data++) {
		for(i=0;i<9;i++)scanf("%x",&chunks[i]);
		key=0;
		for(i=0;i<32;i++) {
			for(sum=0,j=0;j<8;j++)sum+=chunks[j];
			if((sum & (1<<i))!=(chunks[8] & (1<<i)))key|=1<<i;
			for(j=0;j<9;j++)chunks[j]^=(key & 1<<i);
		}
		printf("%x\n",key);
	}
	return 0;
}