import java.util.*

fun lcm(a:Int, b:Int):Int {
    return a * b / gcd(a, b)
}
fun gcd(a:Int, b:Int):Int {
    return when(b){
        0 -> a
        else -> gcd(b, a % b)
    }
}
class Harmony(private val pattern:Int = 0){
    constructor(pattern:String):this(pattern.toInt(16))
    fun merged(other:Harmony):Harmony {
        return Harmony(pattern or other.pattern)
    }
    override fun toString(): String {
        return (pattern / 16).toString(16).capitalize() + (pattern % 16).toString(16).capitalize()
    }
}
class Rythm(private val mHarmonies:Array<Harmony> = Array(1){Harmony()}){
    companion object {
        operator fun invoke(string:String):Rythm{
            val length = string.length / 2
            val array = (0 until string.length step 2).map{string.substring(it, it + 2)}
            val g = array.withIndex().filter{i -> i.value != "00"}.fold(length){l, r -> gcd(l, r.index)}
            return Rythm((0 until length step g).map{Harmony(array[it])}.toTypedArray())
        }
    }
    val length:Int
        get() = mHarmonies.size
    fun mergedSize(rythm: Rythm):Int = lcm(this.length, rythm.length)
    fun merge(rythm: Rythm):Rythm? {
        if (mergedSize(rythm) > 1024) return null
        val res = Array(mergedSize(rythm)){Harmony()}
        val h = res.size / length
        for (i in 0 until length){
            res[i * h] = res[i * h].merged(mHarmonies[i])
        }
        val v = res.size / rythm.length
        for (i in 0 until rythm.length){
            res[i * v] = res[i * v].merged(rythm.mHarmonies[i])
        }
        return Rythm(res)
    }
    override fun toString(): String {
        return mHarmonies.joinToString("") { it.toString()}
    }
}

fun main(args:Array<String>):Unit {
    repeat(readLine()!!.toInt()){
        println(Array(readLine()!!.toInt()){
            readLine()!!.trim()
        }.fold(Rythm() as Rythm?){l, r -> l?.merge(Rythm(r))} ?: "Too complex.")
    }
}
