beecrowd | 1503

Largest Common Palindrome Must You Find

By Jonathan Carvalhosa, IME (Instituto Militar de Engenharia) BR Brazil

Timelimit: 7

Master Yoda has intercepted secret messages from the dark side of the force.

He is sure that all the messages have the same valuable piece of information that can help the Jedi against the Sith

Besides, he knows that the information he seeks is a palindrome.

However, he can`t find it because the messages are too big. That`s why he needs your help.

You have to build a program to find the length of the largest common palindrome of all the messages that Master Yoda intercepted.

Input

The input consists of many test cases and ends with EOF. The first line of each test case contains a single positive integer n (n <= 10), the number of messages Master Yoda intercepted

The next n lines contain the messages, consisting only of between 1 and 50000 lowercase english letters ('a' - 'z')

Output

For each test case, the output is a single integer, the length of the longest common palindrome of all messages

Sample Input Sample Output

3
cabbac
aaaaaaaaaaaaabba
bbbbbaabba
5
i
zypcjig
moswfrzcim
ahzeioe
wjius

4
1