11501150 SUSTech Online Judge
Problem 1150 --Longest Common Substring [Hard]

1150: Longest Common Substring [Hard]

Time Limit: 2 Sec  Memory Limit: 128 MB
Submit: 726  Solved: 179
[Submit][Status][Web Board]

Description

It's hard for Hong to find the longest common substring of N different strings.  Hong wants you to solve this question.

Input

The first line will be an integer T (1≤T≤10), which is the number of test cases.  

For each test data:

The first line contains an integer N (1≤N≤1000) — the number of the sentences.

Each of the next N lines contains a string s, which consists of lowercase letters (no space) only. The length of each string will be at least 1 and at most 200 characters.

Output

For each case please print the lexicographically smallest longest common substring. If there is no such non-empty string, output the words “Hong” instead.

Sample Input

1
3
aabbaabb
abbababb
bbbbbabb

Sample Output

abb

HINT

Source

[Submit][Status]