We consider a string of $n$ characters, indexed $1,2,\dots,n$ . Your task is to calculate all values of the following functions:
Note that the function $z$ is used in the Z-algorithm, and the function $\pi$ is used in the KMP algorithm.
The only input line has a string of length $n$ . Each character is between a–z.
Print two lines: first the values of the $z$ function, and then the values of the $\pi$ function.
abaabca
\n
0 0 1 2 0 0 1 0 0 1 1 2 0 1
· · · · · · \n · · · · · · \n