Time

12:55:37
23 May 2012
Version for print

A-function from a string

   The string S of n characters is given. Lets define the function A(i) that depends on the first i characters of this line as follows: A(i) equals to the maximum possible value of k such that the next two strings are equal:

S[1] + S[2] + S[3] + … + S[k],

S[i] + S[i1] + S[i2] + … + S[ik+1],

   where S[i] is the i-th character of S, and the sigh + means the concatination function.

   Write a program that will find the values of a function A for a given string for all possible values of i from 1 to n.


Specifications

   Input

   The first line contains one number n (1 n200000). The second line contains a string of n uppercase and (or) lowercase latin characters.

   Output

   Print n numbers - the values of function A(1), A(2), … A(n).


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 4.54545
Complexity: 40% 12/20

Example

Example input

5
aabaa

Example output

1 2 0 1 5


← Geme Problems Öèðêîâîå øîó →