409054: GYM103427 M String Problem

Memory Limit:512 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

M. String Problemtime limit per test2.0 smemory limit per test512 megabytesinputstandard inputoutputstandard output

JB hates solving string problems. Therefore, when his friend Potato gives him a string problem to solve, he immediately gives it to you and continues playing Genshin Impact, the greatest game in the world.

You are given a string and then for each nonempty prefix, you need to find the largest substring in lexicographical order and point out the leftmost occurrence of the largest substring.

Input

The only line contains a string $$$S$$$ $$$(1\leq |S|\leq 10^6)$$$, which consists of lowercase Latin letters, a to z.

Output

Output $$$|S|$$$ lines, the $$$i$$$-th of which contains two integers $$$l_i$$$ and $$$r_i$$$, indicating the leftmost occurrence of the largest substring in the prefix of length $$$i$$$.

ExamplesInput
potato
Output
1 1
1 2
3 3
3 4
3 5
5 6
Input
pbpbppb
Output
1 1
1 2
1 3
1 4
1 5
5 6
5 7

加入题单

上一题 下一题 算法标签: