Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>

using namespace std;

typedef unsigned short us;

int N;
int M;

us toHex(string s){
    us num=0;
    for(int j=0;j<=1;j++){
        if(s[j]>='0'&&s[j]<='9')num+=s[j]-'0';
        else num+=s[j]-'A'+10;
        if(j==0)num=(num<<4);
    }
    return num;
}
vector<us> toHexList(string s){
    vector<us> vus;
    for(int i=0;i<s.size();i+=2){
        string ss=s.substr(i,2);
        us num=toHex(ss);
        vus.push_back(num);
    }
    return vus;
}
string toStr(us num){
    us a=num&(0x0F);
    us b=(num&(0xF0))>>4;
    string s;
    if(b>=0&&b<=9)s+=('0'+b);
    else s+=('A'+b-10);
    if(a>=0&&a<=9)s+=('0'+a);
    else s+=('A'+a-10);
    return s;
}

// ³kÅ«éñÈçÎA³k·é
vector<us> dePos(vector<us> vus){
    if(vus.size()==1)return vus;
    int sz=vus.size();
    // iÌå«³ÌñÉ³k·é
    for(int i=1;i<=sz;i++){
        if(sz%i!=0)continue;
        // ³kÅ«é©`FbN
        bool isDecom=true;
        // sz/iÂÌubNÉª
        // »ê¼êÌÓªÇ¤ÈÁÄ¢é©`FbN
        for(int j=0;j<sz;j++){
            if(j%(sz/i)==0)continue;
            else if(vus[j]!=0){
                isDecom=false;
                break;
            }
        }
        // ³kÂ\
        if(isDecom){
            vector<us> res;
            for(int j=0;j<sz;j++){
                if(j%(sz/i)==0){
                    res.push_back(vus[j]);
                }
            }
            return res;
        }
    }
    // ³ks\
    return vus;
}
vector<us> nums[5000];

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}

int main(){

    cin>>N;
    while(N--){
        cin>>M;
        int L=1;
        for(int i=0;i<M;i++){
            string s;
            cin>>s;
            nums[i]=dePos(toHexList(s));
            L=lcm(L,nums[i].size());
        }
        if(L>2000){
            cout<<"Too complex."<<endl;
            continue;
        }
        // »ê¼êÌYp^[ÌTCYÌÅ¬ö{ðæé
        // »Ì·³ÉSÄÌñð²®µA»Ìã¬
        // ¬ãAp^[ð³k·é
        for(int i=0;i<M;i++){
            if(nums[i].size()==L)continue;
            else{
                vector<us> nlis;
                // Yp^[ðL£
                for(int j=0;j<L;j++){
                    if(j%(L/nums[i].size())==0)nlis.push_back(nums[i][j/(L/nums[i].size())]);
                    else nlis.push_back(0);
                }
                nums[i]=nlis;
            }
        }
        vector<us> res;
        // ·³ð²®µ½ ÆA¬
        for(int i=0;i<L;i++){
            us num=0;
            for(int j=0;j<M;j++)num|=nums[j][i];
            res.push_back(num);
        }
        res=dePos(res);
        if(res.size()>1024)cout<<"Too complex."<<endl;
        else{
            for(int i=0;i<res.size();i++)cout<<toStr(res[i]);
            cout<<endl;
        }
    }

    return 0;
}

Compiler output:
a.cc:74:1: error: expected declaration before '}' token
   74 | }
      | ^
a.cc: In function 'std::vector<short unsigned int> dePos(std::vector<short unsigned int>)':
a.cc:71:5: warning: control reaches end of non-void function [-Wreturn-type]
   71 |     }
      |     ^