P5546 [POI 2000] Common Substring

Description

Given several words consisting of lowercase letters, find the length of their longest common substring.

Input Format

The first line of the file is an integer $n$, $1\le n \le 5$, which represents the number of words. The next $n$ lines each contain one word, consisting only of lowercase letters. The length of each word is at least $1$ and at most $2000$.

Output Format

Only one line containing one integer: the length of the longest common substring.

Explanation/Hint

Translated by ChatGPT 5