REPTTS - Repetitions

no tags 

A sequence of words over alphabet [‘a’ ..’z’] is given. The length of longest word occurring as a coherent fragment in every word given is to be found.

Input

In the first line there is an integer n, where 1 <= n <= 5 is the number of words. In each of the next n lines there is one word formed from small letters of English alphabet [‘a’ .. ’z’]. The length of each word is at least 1, but not greater than 2000.

Output

The output should consist of exactly one line containing a single integer equal to the length of the longest word occurring as the coherent fragment in every word given.

Example

Input:
3
abcb
bca
acbc

Output:
2

hide comments
Oleg: 2011-09-13 14:52:28

Yes, seems its easy version of LCS2. Moved to Tutorials.

Last edit: 2011-07-15 09:22:38
Siarhei Kulik: 2011-09-13 14:52:28

Is it the same as LCS2 but with lower constraints?

Krzysztof Lewko: 2011-09-13 14:52:28

@Kashyap, yes

Kashyap Krishnakumar: 2011-09-13 14:52:28

What does a coherent fragment mean? a substring?


Added by:Krzysztof Lewko
Date:2011-07-13
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:VII POI