Kanbun
题号:NC237166
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Paulliant is a linguist. Recently he received an article written in language A and he was told to translate it into language B. The two languages only differ in word order, so, Paulliant decided to translate by redefining the reading order of the articles, and came up with the following method.
Suppose that the article consists of n words, numbered as . Paulliant generated a string str consisting of only '(', ')' and '-', whose length is also n. The string must satisfy the rule of bracket matching. Formally speaking, define and , representing the number of character '(' or ')' within the first i characters of the string, respectively, there is for every and .
The process to read the article obeys the following rules.
  1. The process starts from the first word.
  2. For the i-th word, if str_i is '-' or ')', then read the i-th word directly, and jump to the -th word.
  3. For the i-th word, if str_i is '(', then find the matching right bracket of it. Supposing it to be str_j, read the -th to j-th word, then read the i-th word, and finally jump to the -th word.
  4. If we are to read the -th word (obviously it doesn't exist), the process ends.
Note that the process is recursive, meaning that when reading the -th to j-th word in rule (2), it still follows the four rules.
For example,
  • If , str is "(-)-", the reading order will be 2, 3, 1, 4.
  • If , str is "-((-)-)", the reading order will be 1, 4, 5, 3, 6, 7, 2.
Now, give you the number of words n, and the string str Paulliant generated. Your task is to print the reading order following the four rules. It can be proved that the reading order should be a permutation of numbers from 1 to n.

输入描述:

The first line contains a single integer  --- the number of words.
The second line contains a string str of n characters. It consists of n characters of only '(', ')', '-', and it's guaranteed to satisfy the rules of bracket matching.

输出描述:

Output a line consisting of n integers which represent the reading order, it should be a permutation of numbers from 1 to n. The n integers are separated by spaces.
示例1

输入

复制
4
(-)-

输出

复制
2 3 1 4
示例2

输入

复制
7
-((-)-)

输出

复制
1 4 5 3 6 7 2
示例3

输入

复制
14
((-)-()--)(-)-

输出

复制
3 4 2 5 7 6 8 9 10 1 12 13 11 14