#include <cstdio>
using namespace std;

int main(){
	unsigned n[9], k, t;
	int s;
	for( scanf("%d", &s); s--; ){
		for(int i = 0; i < 9; ++i ){
			scanf("%x", &n[i]);
		}

		k = 0;
		for(int i = 0; i < 32; ++i){
			t = 0;
			for(int j = 0; j < 8; ++j){
				t += n[j] ^ k;
			}
			k |= (t ^ n[8]) & (1 << i);
		}
		printf("%x\n", k);
	}
}