Suffix Sort

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

Grammy has a string SS of length nn that consists of lowercase English letters.

For a string PP, reading it left to right, write down the letters that never occurred before as t_1,t_2,t_3,,t_kt\_1, t\_2, t\_3, \ldots, t\_k. For example, if P=P ="sesame", we write down 's', 'e', 'a', 'm'. The minimal representation R(P)R(P) can be obtained by replacing every occurrence of t_1t\_1 in PP by the first character of the character set ("a"), replacing every occurrence of t_2t\_2 in PP by the second character of the character set ("b"), and so on.

For example, when the character set is lowercase English letters, the minimal representation of "sesame" is "abacdb", the minimal representation of "edcca" is "abccd", and minimal representations R(R("xy")) and R(R("zt")) are both "ab".

Your task is to sort all suffixes of SS by their minimal representation. Formally, denote suffix S_iS_i+1S_n1S_nS\_i S\_{i + 1} \ldots S\_{n - 1} S\_n as S\[i:]S\[i{:}]. For two suffixes S\[i:]S\[i{:}] and S\[j:]S\[j{:}], if R(S\[i:])R(S\[i{:}]) is less than R(S\[j:])R(S\[j{:}]) in lexicographical order, then S\[i:]S\[i{:}] has to occur before S\[j:]S\[j{:}] in the desired order.

Please output the result as an array of indices sa\mathit{sa}: the ii-th element of sa\[i]\mathit{sa}\[i] must be the position of the first character in the ii-th smallest suffix of SS in the desired order. Formally, the array must satisfy R(S\[sa\[1]:])<R(S\[sa\[2]:])<<R(S\[sa\[n]:]).R(S\[\mathit{sa}\[1]{:}]) < R(S\[\mathit{sa}\[2]{:}]) < \ldots < R(S\[\mathit{sa}\[n]{:}])\text{.}

입력

The first line contains one integers nn (1n200,0001 \le n \le 200\\,000).

The next line contains a string SS of length nn. It is guaranteed that SS only consists of lowercase English alphabets.

출력

Output nn integers representing the answer.