Blue Jeans

Time limit1sMemory limit128 MB

Statement

The Genographic Project is a research partnership between IBM and The National Geographic Society that analyzes DNA from hundreds of thousands of contributors to map how the Earth was populated.

As an IBM researcher, you have been asked to write a program that finds the commonalities among given snippets of DNA, which can then be correlated with survey information to identify new genetic markers.

A DNA base sequence is written by listing its nitrogen bases in the order they appear in the molecule. There are four bases: adenine (A), thymine (T), guanine (G), and cytosine (C). A 6-base DNA sequence could be written as TAGACC.

Given several DNA base sequences, find the longest run of consecutive bases (contiguous substring) that appears in every one of the sequences.

Input

The first line contains a single integer $n$, the number of datasets. Each dataset consists of the following:

  1. A single positive integer $m$ ($2 \le m \le 10$), the number of base sequences in this dataset.
  2. $m$ lines, each containing one base sequence of 60 bases.

Output

For each dataset, output the longest contiguous substring common to all of the given base sequences. If this longest common substring is shorter than three bases, output no significant commonalities instead. If several substrings share the same maximum length, output only the one that comes first in alphabetical order.