#abc285b. [abc285_b]Longest Uncommon Prefix

[abc285_b]Longest Uncommon Prefix

Problem Statement

You are given a string SS of length NN consisting of lowercase English letters. The xx-th (1lexleN)(1 \\le x \\le N) character of SS is SxS_x.

For each i=1,2,dots,N1i=1,2,\\dots,N-1, find the maximum non-negative integer ll that satisfies all of the following conditions:

  • l+ileNl+i \\le N, and
  • for all integers kk such that 1leklel1 \\le k \\le l, it holds that SkneqSk+iS_{k} \\neq S_{k+i}.

Note that l=0l=0 always satisfies the conditions.

Constraints

  • NN is an integer such that 2leNle50002 \\le N \\le 5000.
  • SS is a string of length NN consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

NN SS

Output

Print (N1)(N-1) lines. The xx-th (1lex<N)(1 \\le x < N) line should contain the answer as an integer when i=xi=x.


Sample Input 1

6
abcbac

Sample Output 1

5
1
2
0
1

In this input, S=S= abcbac.

  • When i=1i=1, we have S1neqS2,S2neqS3,dotsS_1 \\neq S_2, S_2 \\neq S_3, \\dots, and S5neqS6S_5 \\neq S_6, so the maximum value is l=5l=5.
  • When i=2i=2, we have S1neqS3S_1 \\neq S_3 but S2=S4S_2 = S_4, so the maximum value is l=1l=1.
  • When i=3i=3, we have S1neqS4S_1 \\neq S_4 and S2neqS5S_2 \\neq S_5 but S3=S6S_3 = S_6, so the maximum value is l=2l=2.
  • When i=4i=4, we have S1=S5S_1 = S_5, so the maximum value is l=0l=0.
  • When i=5i=5, we have S1neqS6S_1 \\neq S_6, so the maximum value is l=1l=1.