The longest constant gene

Thousands of genomes, from virus to human, are available in public databases. Each genome is pre- sented as a string of nucleotides: ‘A’, ‘C’, ‘G’, and ‘T’. To study the relationship among organisms, their genomes are analyzed. A sequence of nucleotides is called a constant gene if it appears in all genomes. Given N genomes, your task is to write a pro- gram to find the longest constant gene among these genomes. Input The input file consists of several data sets. The first line of the input file contains the number of data sets which is a positive integer and is not bigger than 20. The following lines describe the data sets. For each data set, the first line contains the integer N (1 < N < 7) indicating the number of genomes. Each line in the next N following lines contains one genome (the length of each genome is limited to one million). Output For each test case, write in one line an integer number indicating the length of the longest constant genome. Sample Input 2 2 ACGGGCGTCGTCCCCGTCGTCGTATC CTCGTCGTCCCCGTCGTCGTGTC 3 ACGACGGCTGCGGTAACCC TTACGGCTGCGGTCCCCTT CCCCCCGTTTACGGCTGCGGTGG Sample Output 18 11