CSES - Aalto Competitive Programming 2024 - wk9 - Homework - Z-array
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You are given a string ss and your task is to calculate the Z-array for the string. The Z-Array for a string is an array that, for each position ii, stores the length of the longest substring starting from ii that matches a prefix of the string.

Input

The input consists of a single line containing a string ss, consisting of lowercase English letters.

Output

Output a single line containing s|s| integers, the values of Z1,Z2,Z3,,ZsZ_1, Z_2, Z_3, \dots, Z_{|s|}.

Constraints

  • 1s1061 \leq |s| \leq 10^6

Example

Input:

aabaaab

Output:

7 1 0 2 3 1 0