#abc287e. [abc287_e]Karuta
[abc287_e]Karuta
Problem Statement
You are given strings consisting of lowercase English letters. Let be the -th of them.
For two strings and , is defined to be the maximum integer that satisfies all of the following conditions:
- The lengths of and are both at least .
- For all integers between and , inclusive, the -th character of and that of are equal.
Find the following value for all :
- $\\displaystyle \\max_{i \\neq j} \\mathrm{LCP}(S_i, S_j)$
Constraints
- is an integer.
- is a string of length at least consisting of lowercase English letters .
- The sum of lengths of is at most .
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain $\\displaystyle \\max_{i \\neq j} \\mathrm{LCP}(S_i, S_j)$.
Sample Input 1
3
abc
abb
aac
Sample Output 1
2
2
1
$\\mathrm{LCP}(S_1, S_2) = 2, \\mathrm{LCP}(S_1, S_3) = 1$, and .
Sample Input 2
11
abracadabra
bracadabra
racadabra
acadabra
cadabra
adabra
dabra
abra
bra
ra
a
Sample Output 2
4
3
2
1
0
1
0
4
3
2
1