#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#include<iostream>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define fir first
#define sec second
#define pb  push_back
#define mp  make_pair

typedef long long ll;

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

void minimize(vector<pair<int,int> > &in,int &num){
  int g=-1;
  if (in.size() == 1){
    if (in[0].sec == 0){
      num=1;
      return;
    }
    g=gcd(in[0].sec,num);
    num/=g;
    in[0].sec/=g;
    return;
  }
  rep(j,in.size()){
    if (in[j].sec == 0);
    else if (g==-1)g=in[j].sec;
    else g=gcd(g,in[j].sec);
  }
  if (g>0 && num%g == 0){
    num/=g;
    rep(j,in.size())in[j].sec/=g;
  }
}

bool check(int n,vector<pair<int,int> > *in,int *num,int l){
  rep(i,n){
    if (l % num[i] != 0)return false;
  }
  
  vector<int> out(l,0);
  rep(i,n){
    int tmp=l/num[i];
    rep(j,in[i].size()){
      out[in[i][j].sec*tmp]|=in[i][j].fir;
    }
  }

  rep(i,out.size())printf("%02X",out[i]);
  printf("\n");  
  return true;
}

void solve(int n,vector<pair<int,int> >*in,int *num){
  REP(i,1,1025){
    if (check(n,in,num,i))return;
  }
  printf("Too complex.\n");
}

int main(){
  int te;
  int num[N];
  vector<pair<int,int> > in[N];
  cin>>te;
  while(te--){
    int n;
    cin>>n;
    rep(i,n){
      in[i].clear();
      string inp;
      cin>>inp;
      num[i]=inp.size()/2;
      rep(j,inp.size()/2){
	if (inp[j*2]=='0'&&inp[j*2+1]=='0')continue;
	in[i].pb(mp(
		    (inp[j*2]-'0')*16+(inp[j*2+1]-'0'),
		    j
		    )
		 );
      }

      if (in[i].size() == 0)num[i]=1;
      minimize(in[i],num[i]);
    }
    solve(n,in,num);
  }
  return false;
}