Under construction

Still being built. Things may change

Hold the Line!

Time limit2sMemory limit1024 MB

Summary
For each position in a string of up to 500000 lowercase letters, find the longest odd-length substring centered there that equals a prefix of the string.
Level

Medium6 of 10

Topics
String matching, String
Solved
No attempts yet

Problem

In the Middle Ages, war was not an extraordinary event. Many states were instead at constant war with their neighbors for decades. Peaceful times were rare, and not everyone lived to see them.

As science advanced, its results were applied to warfare. New weapons and battle tactics appeared, and field medicine developed. Scientific methods were also used to choose the squad sent on each mission.

Before a commander picked a squad for battle, he lined up all the soldiers under his command in a row. Then he chose the soldier who would lead the squad, and only after that chose the squad itself.

According to the latest research by British alchemists, a squad had to consist of an odd number of soldiers standing consecutively in the row. The squad leader had to be the soldier standing in the middle of the chosen group. The last condition was that the first letter of the name of the kk-th soldier from the left in the squad had to match the first letter of the name of the kk-th soldier from the left in the whole row. The alchemists guaranteed victory in any battle when all these requirements were met, so the requirements were enforced strictly.

Following tradition and the principle that "quantity turns into quality," commanders usually gave their leader the most suitable squad under these constraints. Your task is to take the first letters of the names of the soldiers in the row and find, for each soldier, the maximum size of a squad he can command.

Input

The first line of the input file contains the string SS, the first letters of the names of the soldiers in the row. The length of the string does not exceed 500 000500{\,}000. The string consists only of lowercase Latin letters.

Output

The first line of the output file contains ∣S∣|S| integers separated by spaces. The ii-th integer is the maximum size of a squad that the soldier at position ii can command.

Examples1

  1. Example 1

    Input
    abcabc
    
    Expected output
    1 3 5 1 3 0