#include <stdio.h>

int twochar2int(const char* input) {
	char buffer[4];
	int result;
	buffer[0]=input[0];
	buffer[1]=input[1];
	buffer[2]=0;
	sscanf(buffer,"%X",&result);
	return result;
}

int gcd(int a,int b) {
	return b==0?a:gcd(b,a%b);
}

int lcm(int a,int b) {
	return a/gcd(a,b)*b;
}

int main(void) {
	int puttern_length[8];
	unsigned char putterns[8][1024];
	char puttern_buffer[2052];
	int N,i,j;
	int caseNum,caseCount;
	scanf("%d",&caseNum);
	for(caseCount=0;caseCount<caseNum;caseCount++) {
		int max_kouyakusuu;
		int final_length,final_length2;
		scanf("%d",&N);
		for(i=0;i<N;i++) {
			int nonzero_flag=0;
			scanf("%s",puttern_buffer);
			puttern_length[i]=0;
			for(j=0;puttern_buffer[j];j+=2) {
				putterns[i][j/2]=twochar2int(&puttern_buffer[j]);
				if(putterns[i][j/2]!=0)nonzero_flag=1;
				puttern_length[i]++;
			}
			if(!nonzero_flag)puttern_length[i]=1;
		}
		for(i=0;i<N;i++) {
			max_kouyakusuu=-1;
			for(j=1;j<puttern_length[i];j++) {
				if(putterns[i][j]!=0) {
					int now_kouyakusuu=gcd(j,puttern_length[i]);
					if(max_kouyakusuu<0)max_kouyakusuu=now_kouyakusuu;
					else max_kouyakusuu=gcd(max_kouyakusuu,now_kouyakusuu);
				}
			}
			if(max_kouyakusuu>1) {
				for(j=0;j<puttern_length[i];j+=max_kouyakusuu) {
					putterns[i][j/max_kouyakusuu]=putterns[i][j];
				}
				puttern_length[i]/=max_kouyakusuu;
			}
		}
		final_length=puttern_length[0];
		for(i=1;i<N && final_length<=1024;i++) {
			final_length=lcm(final_length,puttern_length[i]);
		}
		final_length2=final_length;
		max_kouyakusuu=-1;
		for(i=1;i<final_length;i++) {
			int now=0;
			for(j=0;j<N;j++) {
				if((i*puttern_length[j])%final_length==0) {
					now|=putterns[j][i*puttern_length[j]/final_length];
				}
			}
			if(now!=0) {
				int now_kouyakusuu=gcd(i,final_length);
				if(max_kouyakusuu<0)max_kouyakusuu=now_kouyakusuu;
				else max_kouyakusuu=gcd(max_kouyakusuu,now_kouyakusuu);
			}
		}
		if(max_kouyakusuu>1) {
			final_length2=final_length/max_kouyakusuu;
		} else max_kouyakusuu=1;
		if(final_length2>1024) {
			puts("Too complex.");
		} else {
			for(i=0;i<final_length;i+=max_kouyakusuu) {
				int now=0;
				for(j=0;j<N;j++) {
					if((i*puttern_length[j])%final_length==0) {
						now|=putterns[j][i*puttern_length[j]/final_length];
					}
				}
				printf("%02X",now);
			}
			putchar('\n');
		}
	}
	return 0;
}