{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n S是一个由n个左括号与n个右括号组成的字符串,它有两种编码方式: \n \u003cbr\u003e1. P是一个由n个整数组成的序列。它是由每一个右括号左边的左括号个数组成。\n \u003cbr\u003e2. W是一个由n个整数组成的序列。它是每一个右括号匹配的左括号和该右括号之间的右括号个数。\n \u003cbr\u003e \n \u003cbr\u003e接下来是一个例子: \n \u003cbr\u003e\n \u003cpre\u003e\n\u003cbr\u003e\tS\t\t(((()()())))\n\u003cbr\u003e\tP-sequence\t 4 5 6666\n\u003cbr\u003e\tW-sequence\t 1 1 1456\n\u003cbr\u003e\u003c/pre\u003e \n\n \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n The first line of the input contains a single integer t (1 \u0026lt;\u003d t \u0026lt;\u003d 10), the number of test cases, followed by the input data for each test case. The first line of each test case is an integer n (1 \u0026lt;\u003d n \u0026lt;\u003d 20), and the second line is the P-sequence of a well-formed string. It contains n positive integers, separated with blanks, representing the P-sequence.\n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n The output file consists of exactly t lines corresponding to test cases. For each test case, the output line should contain n integers describing the W-sequence of the string corresponding to its given P-sequence.\n \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e2\n6\n4 5 6 6 6 6\n9 \n4 6 6 6 6 8 9 9 9\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e1 1 1 4 5 6\n1 1 2 4 5 1 1 3 9\u003c/pre\u003e"}}]}