Longest Lyndon Prefix

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

문제

A word ww is a lyndon word if and only if it is strictly smaller than all its proper suffixes. For example, aab is a lyndon word, while aa is not a lyndon word.

Chiaki has a string s_1s_2s_ns\_1s\_2\dots s\_n of length nn. She would like to know l_il\_i, that is the length of the longest prefix of s_is_i+1s_ns\_i s\_{i + 1} \dots s\_{n} which is a lyndon word.

입력

There are multiple test cases. The first line of the input contains an integer TT (1T1051 \le T \le 10^5), indicating the number of test cases. For each test case:

The first line contains an integer nn (1n1051 \leq n \leq 10^5). The second line contains a string s_1s_2s_ns\_1 s\_2 \dots s\_n consists of lowercase characters.

The sum of all nn does not exceed 10510^5.

출력

For each test case, output nn integers denoting l_1,l_2,,l_nl\_1, l\_2, \dots, l\_n.