#P15432. [ICPC 2026 APC] Compare Suffixes

[ICPC 2026 APC] Compare Suffixes

Problem Description

This task was originally an interactive problem from ICPC Asia Pacific Championship 2026. For Hydro OJ, it has been converted into a normal output-checking problem.

You are given a lowercase string SS of length nn. For an integer kk (1kn)(1 \le k \le n), let S(k)S(k) denote the suffix of SS starting from the kk-th character.

Your task is to output a permutation (p1,p2,,pn)(p_1,p_2,\ldots,p_n) of (1,2,,n)(1,2,\ldots,n) such that

S(p1)<S(p2)<<S(pn)S(p_1) < S(p_2) < \cdots < S(p_n)

in lexicographical order.

Because all suffixes starting at different positions are distinct, the answer is unique.

Input Format

The input contains one line: a lowercase string SS.

The special judge also supports the format n S, but the recommended data format is a single string line.

Output Format

Output nn integers p1,p2,,pnp_1,p_2,\ldots,p_n, representing the starting positions of all suffixes in increasing lexicographical order.

For compatibility with the original interactive statement, the special judge also accepts the format:

answer p1 p2 ... pn

However, in this Hydro version, contestants should not output query operations.

Constraints

2n10002 \le n \le 1000

SS consists only of lowercase Latin letters a to z.

Sample

Input

icpc

Output

4 2 1 3

Explanation

For S=icpcS=\texttt{icpc}, the suffixes are:

  • S(1)=icpcS(1)=\texttt{icpc}
  • S(2)=cpcS(2)=\texttt{cpc}
  • S(3)=pcS(3)=\texttt{pc}
  • S(4)=cS(4)=\texttt{c}

Their lexicographical order is:

S(4)<S(2)<S(1)<S(3)S(4) < S(2) < S(1) < S(3)

so one valid output is 4 2 1 3.