CF2096A.Wonderful Sticks

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Wonderful Sticks

You are the proud owner of nn sticks. Each stick has an integer length from 11 to nn. The lengths of the sticks are distinct.

You want to arrange the sticks in a row. There is a string ss of length n1n - 1 that describes the requirements of the arrangement.

Specifically, for each ii from 11 to n1n - 1:

  • If si= \lts_i = \texttt{ \lt }, then the length of the stick at position i+1i + 1 must be smaller than all sticks before it;
  • If si= \gts_i = \texttt{ \gt }, then the length of the stick at position i+1i + 1 must be larger than all sticks before it.

Find any valid arrangement of sticks. We can show that an answer always exists.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains a single integer nn (2n1002 \le n \le 100) — the number of sticks.

The second line of each test case contains a single string ss of length n1n - 1 consisting of characters \lt and \gt — describing the requirements of the arrangement.

Output

For each test case, output nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ain1 \leq a_i \leq n, the aia_i are distinct) — the lengths of the sticks in order. If there are multiple solutions, print any of them.

Note

For the first test case, the requirements of the arrangement are as follows:

  • s1= \lts_1 = \texttt{ \lt }, which means a2a_2 is smaller than a1a_1.

Thus, one possible arrangement is [2,1][2, 1].

For the second test case, the requirements of the arrangement are as follows:

  • s1= \lts_1 = \texttt{ \lt }, which means a2a_2 is smaller than a1a_1;
  • s2= \lts_2 = \texttt{ \lt }, which means a3a_3 is smaller than a1a_1 and a2a_2;
  • s3= \gts_3 = \texttt{ \gt }, which means a4a_4 is larger than a1a_1, a2a_2, and a3a_3;
  • s4= \lts_4 = \texttt{ \lt }, which means a5a_5 is smaller than a1a_1, a2a_2, a3a_3, and a4a_4.

Thus, one possible arrangement is [4,3,2,5,1][4, 3, 2, 5, 1].

Samples

5
2
<
5
<<><
2
>
3
<>
7
><>>><
2 1 
4 3 2 5 1 
1 2 
2 1 3 
3 4 2 5 6 7 1 

在线编程 IDE

建议全屏模式获得最佳体验