#ABC285B. [ABC285B] Longest Uncommon Prefix

[ABC285B] Longest Uncommon Prefix

Score : 200200 points

Problem Statement

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

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

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

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

Constraints

  • NN is an integer such that 2N50002 \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 (1x<N)(1 \le x < N) line should contain the answer as an integer when i=xi=x.

6
abcbac
5
1
2
0
1

In this input, S=S= abcbac.

  • When i=1i=1, we have S1S2,S2S3,S_1 \neq S_2, S_2 \neq S_3, \dots, and S5S6S_5 \neq S_6, so the maximum value is l=5l=5.
  • When i=2i=2, we have S1S3S_1 \neq S_3 but S2=S4S_2 = S_4, so the maximum value is l=1l=1.
  • When i=3i=3, we have S1S4S_1 \neq S_4 and S2S5S_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 S1S6S_1 \neq S_6, so the maximum value is l=1l=1.