You are given an integer $$$n$$$ and a binary string$$$^{\text{∗}}$$$ $$$s$$$ of length $$$n$$$.
For a permutation$$$^{\text{†}}$$$ $$$p$$$ of length $$$n$$$ and an integer $$$x$$$, we define $$$\text{find}(x)$$$ as in the following pseudocode:
function find(int x):
l := 1
r := n
while l <= r:
let m be a random integer between l and r (inclusive)
if p[m] == x
return m
if p[m] > x:
r := m - 1
else:
l := m + 1
return undefined // not found
We call an integer $$$x$$$ ($$$1\le x\le n$$$) stable if and only if $$$\text{find}(x)$$$ is always not undefined and $$$p_{\text{find}(x)}=x$$$ always holds, no matter how the value of $$$m$$$ is selected in the process of the pseudocode.
You have to construct a permutation $$$p$$$ of length $$$n$$$, such that:
Or determine that no such permutation exists.
$$$^{\text{∗}}$$$A binary string is a string where each character is either $$$\mathtt{0}$$$ or $$$\mathtt{1}$$$.
$$$^{\text{†}}$$$A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array), and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$2\le n \le 2\cdot 10^5$$$) — the length of the permutation.
The second line contains the binary string $$$s$$$ of length $$$n$$$ ($$$s_i=\mathtt{0}$$$ or $$$\mathtt{1}$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case:
You can output the token in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
If there are multiple answers, you may print any of them.
6311150000051010070010000110000100110012011100010000
YES1 2 3YES2 4 3 5 1NOYES2 1 3 5 7 6 4YES2 1 4 3 5 7 6 8 9 11 10NO
In the first test case, we have constructed $$$p=[1,2,3]$$$. Take $$$\text{find(2)}$$$ as an example:
So $$$p_{\text{find}(2)}= p_2 = 2$$$ always holds, and the integer $$$2$$$ is stable.
Similarly, we can show that integers $$$1$$$ and $$$3$$$ are also stable. Thus, the permutation $$$p = [1, 2, 3]$$$ is a valid answer.
In the second test case, we have constructed $$$p=[2,4,3,5,1]$$$. Take $$$\text{find(3)}$$$ as an example:
Thus, the return value of $$$\text{find}(3)$$$ is undefined, so the integer $$$3$$$ is not stable.
Similarly, we can show that integers $$$1$$$, $$$2$$$, $$$4$$$, and $$$5$$$ are also not stable. Thus, $$$p = [2, 4, 3, 5, 1]$$$ is a valid answer.
Some other permutations, such as $$$p=[5,4,3,2,1]$$$ and $$$p=[3,5,1,4,2]$$$, are also valid answers. You may print any of them.
In the third test case, it can be proven that no such permutation exists.