/*
AizuOnline A2105
Rhythm Machine
2013/01/04 RE
2013/01/06 WA
*/
#define DEBUG 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLEN 1024
unsigned char input_data[2*MAXLEN+1];
unsigned char rythm_pattern[8][MAXLEN];
int  rythm_len[8];
unsigned char result_pattern[MAXLEN];
int N;  /*lines*/
int NN; /*#of dataset*/
unsigned char pat2[MAXLEN];
unsigned char buf[MAXLEN];

long long gcd(long long x, long long y){
	return y == 0 ? x: gcd(y, x%y);
}

long int lcm(long int x,long int y)
{
  return(x/gcd(x,y)*y);
}

void expand_rythm_times(char *r_p,int len,int times)
{
  int i;
  char buf[MAXLEN];
  
  for(i=0;i<MAXLEN;i++)
    buf[i]=0;

  for(i=0;i<len;i++)
    {
      buf[i*times]=r_p[i];
    }
  for(i=0;i<MAXLEN;i++)
    r_p[i]=0;

  for(i=0;i<len*times;i++)
    r_p[i]=buf[i];
}

void logical_or_rythm_patterns(int N)
{ 
  int i,j;  

  //printf("LOR:N %d\n",N);

  for(i=0;i<MAXLEN;i++)
    result_pattern[i]=0;
  for(i=0;i<N;i++)
    for(j=0;j<MAXLEN;j++)
      result_pattern[j] |= rythm_pattern[i][j];
}
void display_rythm_pattern(char * pat,int len)
{
  int i;
  
  for(i=0;i<len;i++)
    printf("%02hhX",pat[i]);
  printf("\n");
}

int shrink_a(char * pat,int n)
{
  int i,j;
  
  for(i=n;i>=1;i--)
    { 
      
      if(n % i == 0)
	{
	
	for(j=1;j<n;j++)
	  if((j % i) && pat[j])
	    goto CONT;
	//printf("%d %d\n",i,j);	
	if(i<n)
	  for(j=i;j<n;j+=i)
	    {
	      //printf("*");
	      pat[j/i]=pat[j];
	    }
	      //pat[j]=0;
	  goto END;
	    
CONT:
	;
	}
    }
      return(0);
END:
      return(n/i);
}
void shrink(int bufnum)
{
  char *pat;
  int  n,n2;
  pat = (char *)&(rythm_pattern[bufnum]);
  n = rythm_len[bufnum];
  //printf("rl:%d\n",n);
  n2=shrink_a(pat,n);
  rythm_len[bufnum]=n2;
}

main()
{
  int ii,i,j,len,lcm_all;
  unsigned int byt;

  int N,NN;
  
  scanf("%d ",&NN);
  
  ii=0; 
  
	
  LOOPY:
     scanf("%d ",&N);

     //   printf("==%d\n",N);
    for(i=0;i<N;i++)
      {
	
	scanf("%s",input_data);
	// printf("--INF 01*:%s\n",input_data);
	rythm_len[i]=len=strlen(input_data)/2;
	    
	for(j=0;j<len;j++)
	  {

	    strncpy(buf,&input_data[j*2],2);
	    sscanf(buf,"%x ",&byt);
	    rythm_pattern[i][j]=(char)(byt & 0xff) ;
	    
	  }

      }
    lcm_all=1;

#ifdef DEBUGx
    printf("--INF 00 \n");
    printf("--INF 00*:%d\n,rythm_pattern[i][7]");
    for(i=0;i<N;i++)
      display_rythm_pattern(&rythm_pattern[i][0],rythm_len[i]);
#endif
    
    for(i=0;i<N;i++)
      {
	shrink(i); 
      }

#ifdef DEBUGx
    printf("--INF 01 \n");
    for(i=0;i<N;i++)
      display_rythm_pattern(&rythm_pattern[i][0],rythm_len[i]);
#endif

    for(i=0;i<N;i++)
      lcm_all = lcm(lcm_all,rythm_len[i]);
    
    if(lcm_all > 1024)
      {
	printf("Too complex.\n");
	goto NEXTLOOP;
      }
    
#ifdef DEBUGx
    printf("--INF 02 \n");
    for(i=0;i<N;i++)
      display_rythm_pattern(&rythm_pattern[i][0],rythm_len[i]);
#endif
    for(i=0;i<N;i++)
      {
	expand_rythm_times(&rythm_pattern[i][0],
			   rythm_len[i],lcm_all/rythm_len[i]);
	rythm_len[i] *= (lcm_all/rythm_len[i]);
      }
#ifdef DEBUGx
    printf("--INF 03 \n");
    for(i=0;i<N;i++)
      display_rythm_pattern(&rythm_pattern[i][0],rythm_len[i]);
#endif

    logical_or_rythm_patterns(N);

    display_rythm_pattern(result_pattern,lcm_all);
    
 NEXTLOOP:
    ii++;
    //printf("**%d %d\n",ii,NN);
    if(ii>=NN)goto END;

    goto LOOPY;
    //}
 END:
return(0);
}