You are given an integer N and a (0-indexed) binary string A having length N+1. 

Find any permutation P of {0,1,2,...,N-1} (or determine that it does not exist) that satisfies the following conditions for all i (0 ≤ i ≤ N): 
if A_{i} = 0: No contiguous segment of P has \texttt{mex} equal to i 
if A_{i} = 1: There exists at least one contiguous segment of P that has \texttt{mex} equal to i

If multiple permutations exist that satisfy the given conditions, print any.

Note: \texttt{mex} of a segment is the smallest non-negative number that does not occur in that segment.

------ Input Format ------ 

- The first line contains the number of test cases T. Description of the test cases follows.
- The first line of each test case contains a single integer N.
- The second line of each test case contains the binary string A of length N + 1.

------ Output Format ------ 

For each test case print :
- \texttt{Yes} if there exists a permutation P that satisfies the conditions described in the statement, followed by the permutation P in the next line (If multiple permutations exist that satisfy the given conditions, print any).
- \texttt{No} otherwise.

You may print each character of \texttt{Yes} and \texttt{No} in uppercase or lowercase (for example, \texttt{yes}, \texttt{yEs}, \texttt{YES} will be considered identical).

------ Constraints ------ 

$1 ≤ T ≤  10^{4}$
$2 ≤ N ≤ 3 \cdot 10^{5}$
$|A| = N + 1$
- It is guaranteed that the sum of $N$ over all test cases does not exceed $3 \cdot 10^{5}$.

----- Sample Input 1 ------ 
4
2
111
5
110100
5
110101
7
11100111

----- Sample Output 1 ------ 
Yes
0 1
No
Yes
0 2 1 4 3
Yes
0 1 3 4 2 5 6

----- explanation 1 ------ 
Test case-1: One of the possible permutations satisfying the given conditions is [$0, 1$] because:
- $\texttt{mex}([1]) = 0$. Therefore the condition is satisfied for $i = 0$.
- $\texttt{mex}([0]) = 1$. Therefore the condition is satisfied for $i = 1$.
- $\texttt{mex}([0, 1]) = 2$. Therefore the condition is satisfied for $i = 2$.

Test case-2: It can be proven that no permutation exists that satisfies the given conditions.

Test case-3: One of the possible permutations satisfying the given conditions is [$0, 2, 1, 4, 3$] because:
- $\texttt{mex}([2]) = 0$. Therefore the condition is satisfied for $i = 0$.
- $\texttt{mex}([0, 2]) = 1$. Therefore the condition is satisfied for $i = 1$.
- There does not exist any segment with $\texttt{mex} = 2$. Therefore the condition is satisfied for $i = 2$.
- $\texttt{mex}([0, 2, 1]) = 3$. Therefore the condition is satisfied for $i = 3$.
- There does not exist any segment with $\texttt{mex} = 4$. Therefore the condition is satisfied for $i = 4$.
- $\texttt{mex}([0, 2, 1, 4, 3]) = 5$. Therefore the condition is satisfied for $i = 5$.

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Constructive algorithms


Solutions:
testcase = int(input())
for case in range(testcase):
	n = int(input())
	arr = input()
	if arr[0] == '0' or arr[1] == '0' or arr[n] == '0':
		print('No')
	else:
		print('Yes')
		ans = [0]
		mex = []
		mex_n = []
		for i in range(1, n):
			if arr[i] == '1':
				mex.append(i)
			else:
				mex_n.append(i)
		ans += mex_n + mex
		for i in ans:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	l = input()
	ans = list(range(n))
	if l[0] == '0' or l[1] == '0' or l[-1] == '0':
		print('No')
	else:
		print('Yes')
		for i in range(2, n):
			if l[i] == '0':
				(ans[i - 1], ans[i]) = (ans[i], ans[i - 1])
		for i in ans:
			print(i, end=' ')
		print()


import math, os, io, heapq
from functools import reduce
from sys import stdin, stdout
from collections import Counter, deque, defaultdict
from itertools import product
import bisect

def getList(method=int):
	return list(map(method, input().split()))

def getInt():
	return int(input())

def solve():
	(n, s) = (getInt(), input())
	if s[-1] == '0' or s[0] == '0' or s[1] == '0':
		print('No')
		return
	(inc, exc) = ([], [])
	for i in range(2, n):
		if s[i] == '1':
			inc.append(i)
		else:
			exc.append(i)
	print('Yes')
	print(*[0, *exc, 1, *inc])
for _ in range(getInt()):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	if not (s[0] == '0' or s[1] == '0' or s[n] == '0'):
		print('Yes')
		temp = 1
		index = 2
		print(0, end=' ')
		while index < n:
			if s[index] == '0':
				print(index, end=' ')
			else:
				print(temp, end=' ')
				temp = index
			index += 1
		print(temp, end=' ')
		print()
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = [i for i in range(n)]
	for i in range(n):
		if s[i] == '0':
			(l[i], l[i - 1]) = (l[i - 1], l[i])
	if s[n] == '1' and s[0] == '1' and (s[1] == '1'):
		print('Yes')
		print(*l)
	else:
		print('No')


testcase = int(input())
for case in range(testcase):
	n = int(input())
	b = input()
	if b[0] == '0' or b[1] == '0' or b[-1] == '0':
		print('No')
	else:
		print('Yes')
		mex = []
		mex_notneeded = []
		ans = ['0']
		for i in range(1, n):
			if b[i] == '1':
				mex.append(i)
			else:
				mex_notneeded.append(i)
		for j in range(len(mex_notneeded)):
			ans.append(str(mex_notneeded[j]))
		for k in range(len(mex)):
			ans.append(str(mex[k]))
		print(' '.join(ans))


for T in range(int(input())):
	N = int(input())
	A = input()
	if A[0] == '0' or A[1] == '0' or A[N] == '0':
		print('No')
	else:
		(L1, L2) = ([0], [1])
		for i in range(2, N):
			L1.append(i) if A[i] == '0' else L2.append(i)
		print('Yes')
		print(*L1, *L2, sep=' ')


testcase = int(input())
for case in range(testcase):
	n = int(input())
	b = input()
	if b[0] == '0' or b[1] == '0' or b[-1] == '0':
		print('No')
	else:
		print('Yes')
		mex_possible = []
		mex_notneeded = []
		for i in range(1, n):
			if b[i] == '1':
				mex_possible.append(i)
			else:
				mex_notneeded.append(i)
		ans = [0]
		for x in range(len(mex_notneeded)):
			ans.append(mex_notneeded[x])
		for y in range(len(mex_possible)):
			ans.append(mex_possible[y])
		print(*ans)


import sys
int1 = lambda x: int(x) - 1
pDB = lambda *x: print(*x, end='\n', file=sys.stderr)
p2D = lambda x: print(*x, sep='\n', end='\n\n', file=sys.stderr)

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 4294967295
md = 10 ** 9 + 7

def solve():
	n = II()
	s = SI()
	if s[0] == '0' or s[1] == '0' or s[-1] == '0':
		print('No')
		return
	ll = [0]
	rr = [1]
	for (i, c) in enumerate(s[2:-1], 2):
		if c == '0':
			ll.append(i)
		else:
			rr.append(i)
	print('Yes')
	print(*ll + rr)
testnumber = II()
for testcase in range(testnumber):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if s[0] == '0' or s[1] == '0' or s[-1] == '0':
		print('No')
		continue
	(zr, on) = ([0], [1])
	for (i, vl) in enumerate(s[2:-1], start=2):
		if vl == '1':
			on.append(i)
		else:
			zr.append(i)
	print('Yes')
	for i in zr + on:
		print(i, end=' ')
	print()


try:
	for _ in range(int(input())):
		n = int(input())
		array = input()
		ans = []
		if array == '01':
			ans = '0'
		elif array[-1] == '0' or array[0] == '0' or array[1] == '0' or (n == 1):
			ans = -1
		else:
			for i in range(n):
				if array[i] == '1':
					ans.append(i)
				else:
					a = ans.pop(-1)
					ans.append(i)
					ans.append(a)
		if ans == -1:
			print('No')
		else:
			print('Yes')
			print(*ans)
except:
	pass


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 10 ** 9 + 7
t = inp()
for i in range(t):
	n = inp()
	s = strng()
	if s[0] != '1' or s[1] != '1' or s[n] != '1':
		print('No')
		continue
	nmexs = []
	ymexs = []
	print('Yes')
	for i in range(2, n):
		if s[i] == '1':
			ymexs.append(i)
		else:
			nmexs.append(i)
	ymexs.sort()
	print(*[0] + nmexs + [1] + ymexs)


for _ in range(int(input())):
	n = int(input())
	s = input()
	m = n + 1
	if s[0] == '0' or s[1] == '0' or s[-1] == '0':
		print('No')
	else:
		ans = [0]
		aa = []
		for i in range(1, n):
			if s[i] == '0':
				ans.append(i)
			else:
				aa.append(i)
		ans = ans + aa
		print('Yes')
		print(*ans, sep=' ')


for _ in range(int(input())):
	n = int(input()) + 1
	s = list(input())
	out = []
	if int(s[0]) == 0 or int(s[1]) == 0 or int(s[-1]) == 0:
		print('No')
		continue
	print('Yes')
	out = []
	out.append(0)
	i = 2
	while int(s[i] == 1) and i < n:
		out.append(i - 1)
		i += 1
	(x, y) = (i, i - 1)
	while x < n:
		if int(s[x]) == 0:
			out.append(x)
		else:
			out.append(y)
			y += 1
			while int(s[y]) == 0:
				y += 1
		x += 1
	print(*out)


import math
import os
import random
import re
import sys
T = int(input())
for _ in range(T):
	N = int(input())
	A = input()
	B = []
	if A[0] == '0' or A[1] == '0' or A[N] == '0':
		print('No')
	else:
		B.append(0)
		c = 1
		for i in range(2, len(A) - 1):
			if A[i] == '0':
				B.append(i)
			else:
				B.append(c)
				c = i
		B.append(c)
		print('Yes')
		print(*B)


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	if s[0] == '0' or s[1] == '0' or s[-1] == '0':
		print('No')
	else:
		mex = []
		n_mex = []
		for i in range(1, len(s)):
			if s[i] == '1':
				mex.append(i)
			else:
				n_mex.append(i)
		ans = [0]
		for i in n_mex:
			ans.append(i)
		for j in range(len(mex) - 1):
			ans.append(mex[j])
		print('Yes')
		print(*ans)


from math import *
from collections import *
import os
from io import BytesIO, IOBase
import sys
from bisect import *
from heapq import *
MOD = 1000000007

def binpow(a, b, m):
	a %= m
	x = 1
	while b > 0:
		if b & 1:
			x = x * a % m
		a = a * a % m
		b >>= 1
	return x

def binser(arr, l, r, x):
	while l < r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return mid

def lcm(a, b):
	return a * b // gcd(a, b)

def sod(n):
	l = list(str(n))
	s = 0
	for i in l:
		s += int(i)
	return s

def prime_factors(num):
	l = []
	if num % 2:
		l.append(2)
	while num % 2 == 0:
		num = num / 2
	for i in range(3, int(sqrt(num)) + 1, 2):
		if not num % i:
			l.append(i)
		while num % i == 0:
			num = num / i
	if num > 2:
		l.append(num)
	return l

def factmod(n, p):
	f = defaultdict(int)
	f[0] = 1
	for i in range(1, n + 1):
		f[i] = f[i - 1] * i % MOD
	return f

def largestPower(n, p):
	x = 0
	while n:
		n //= p
		x += n
	return x

def modFact(n, p):
	if n >= p:
		return 0
	res = 1
	isPrime = [1] * (n + 1)
	i = 2
	while i * i <= n:
		if isPrime[i]:
			for j in range(2 * i, n, i):
				isPrime[j] = 0
		i += 1
	for i in range(2, n):
		if isPrime[i]:
			k = largestPower(n, i)
			res = res * binpow(i, k, p) % p
	return res

def drec(x, y):
	if y == x + 1:
		return 'R'
	if y == x - 1:
		return 'L'
	if x < y:
		return 'D'
	return 'U'

def cellhash(x, y):
	return (x - 1) * m + y

def bins(l, x, n):
	i = bisect_left(l, x)
	if i < n:
		return i
	if i:
		return i - 1
	else:
		return n

def cond(l):
	for i in range(len(l) - 1):
		if l[i] == str(int(l[i + 1]) - 1):
			return False
	return True

def isvowel(s):
	if s in list('aeiou'):
		return 1
	return 0

def countOdd(L, R):
	N = (R - L) // 2
	if R % 2 != 0 or L % 2 != 0:
		N += 1
	return N

def tst(A, B, C):
	return (A | B) & (B | C) & (C | A)

def palcheck(n, s):
	(i, j) = (0, n - 1)
	while i <= j:
		if s[i] == s[j]:
			return False
		i += 1
		j -= 1
	return True

def sakurajima(n):
	if n < 9:
		n = 10
	l = [1] * (n + 1)
	l[1] = 0
	for i in range(2, int(n ** 0.5) + 1):
		if l[i]:
			for j in range(i * i, n + 1, i):
				if not j % i:
					l[j] = 0
	return l

def prchck(n):
	l = [1] * (n + 1)
	l[1] = 0
	for i in range(2, n + 1):
		for j in range(2, int(sqrt(n)) + 1):
			if j % i == 0:
				l[j] = 1
	return l

def ispal(s, n):
	for i in range(n // 2):
		if s[i] != s[n - i - 1]:
			return False
	return True

def bfs(src, dest, ajl, vis):
	q = deque([src])
	vis[src] = True
	while q:
		i = q.popleft()
		if i == dest:
			return True
		for j in ajl[i]:
			if not vis[j]:
				vis[j] = True
				q.append(j)
	return False

def dfs(i, ajl, vis):
	vis[i] = True
	for j in ajl[i]:
		if not vis[j]:
			dfs(j, ajl, vis)

class DisjSet:

	def __init__(self, n):
		self.rank = [1] * n
		self.parent = [i for i in range(n)]

	def find(self, x):
		if self.parent[x] != x:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def Union(self, x, y):
		xset = self.find(x)
		yset = self.find(y)
		if xset == yset:
			return
		if self.rank[xset] < self.rank[yset]:
			self.parent[xset] = yset
		elif self.rank[xset] > self.rank[yset]:
			self.parent[yset] = xset
		else:
			self.parent[yset] = xset
			self.rank[xset] = self.rank[xset] + 1

def snek(i, ajl, vis, x, ds):
	vis[i] = True
	for j in ajl[i]:
		if not vis[j]:
			ds[j] = x
			snek(j, ajl, vis, x, ds)

def panda(n, s):
	if s[0] == '0' or s[1] == '0' or s[n] == '0':
		print('No')
		return
	ans = [0]
	x = 1
	for i in range(2, n):
		if s[i] == '0':
			ans.append(i)
		else:
			ans.append(x)
			x = i
	ans.append(x)
	print('Yes')
	print(*ans)
t = 1
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	panda(n, s)


for _ in range(int(input())):
	N = int(input())
	A = input()
	if A[0] == '0' or A[1] == '0' or A[-1] == '0':
		print('No')
	else:
		Arr = []
		for i in range(N):
			Arr.append(i)
			if A[i] == '0':
				(Arr[i], Arr[i - 1]) = (Arr[i - 1], Arr[i])
		print('Yes')
		for i in Arr:
			print(i, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	if (s[0] == '0' or s[1] == '0') or s[-1] == '0':
		print('No')
	elif n == 1:
		print('Yes')
		print(0)
	elif n == 2:
		print('Yes')
		print('0 1')
	else:
		print('Yes')
		l = [0] * n
		sum = 0
		a = ''
		ans = '0 '
		for i in range(2, len(s)):
			if s[i] == '0':
				a = str(i - 1) + ' ' + a
			else:
				a = str(i - 1) + ' ' + a
				ans = ans + a
				a = ''
		ans = ans + a
		print(ans)


from itertools import permutations
import os.path
from math import gcd, floor, ceil
from collections import *
from random import randint
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = inp()
	s = st()
	if s[0] == '0' or s[1] == '0' or s[-1] == '0':
		pr('No')
		return
	ind = -1
	l = list(range(n))
	for i in range(n - 1, -1, -1):
		if s[i] == '0':
			ind = i
			break
	if ind == -1:
		pr('Yes')
		print(*l)
	else:
		index = {i: i for i in range(n)}
		for i in range(1, ind + 1):
			if s[i] == '0':
				(l[i], l[i - 1]) = (l[i - 1], l[i])
		pr('Yes')
		print(*l)
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = input()
	if a[n] == '0' or a[1] == '0' or a[0] == '0':
		print('No')
	elif a.count('1') == n + 1:
		print('Yes')
		for i in range(n):
			print(i, end=' ')
		print()
	else:
		f = -1
		c = 0
		print('Yes')
		print(0, end=' ')
		for i in range(2, n + 1):
			if a[i] == '1' and f == -1:
				print(i - 1, end=' ')
			elif a[i] == '1' and f != -1:
				print(f, end=' ')
				f = -1
				c = 0
			else:
				print(i, end=' ')
				if c == 0:
					f = i - 1
					c = 1
		print()


def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def rm():
	return map(int, input().split())
for _ in range(ri()):
	n = ri()
	a = input()
	if a[0] == '0' or a[1] == '0' or a[-1] == '0':
		print('No')
		continue
	print('Yes')
	j = 1
	l = []
	i = 0
	f = 0
	for k in range(n + 1):
		if i == n:
			break
		if a[i] == '1':
			if a[j] == '1':
				l.append(i)
				i = j
				j += 1
			else:
				l.append(j)
				j += 1
	print(*l)


import math
for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[0] == '0' or s[1] == '0' or s[n] == '0':
		print('No')
	else:
		l = []
		l.append(0)
		h = 1
		for i in range(2, len(s) - 1):
			if s[i] == '0':
				l.append(i)
			else:
				l.append(h)
				h = i
		l.append(h)
		print('Yes')
		for i in l:
			print(i, end=' ')
		print()


for i in range(int(input())):
	n = int(input())
	s = input()
	if s[n] == '0' or s[0] == '0' or s[1] == '0':
		print('No')
		continue
	nlist = []
	for j in range(n + 1):
		nlist.append(j)
	for j in range(n):
		if s[j + 1] == '0':
			(nlist[j], nlist[j + 1]) = (nlist[j + 1], nlist[j])
	if nlist[n - 1] == 0:
		print('No')
	else:
		print('Yes')
		print(*nlist[:n])


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[0] == '0' or s[1] == '0' or s[n] == '0':
		print('No')
	else:
		ans = []
		ans.append(0)
		you = 1
		for i in range(2, len(s) - 1):
			if s[i] == '0':
				ans.append(i)
			else:
				ans.append(you)
				you = i
		ans.append(you)
		print('Yes')
		for hh in ans:
			print(hh, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input().rstrip()
	a = []
	if s[0] == '0' or s[-1] == '0' or s[1] == '0':
		print('No')
	else:
		i = 0
		while i < n:
			if s[i] == '1':
				if s[i + 1] == '1':
					a.append(i)
					i += 1
				else:
					idx = -1
					for j in range(i + 1, n + 1):
						if s[j] == '1':
							idx = j
							break
						else:
							a.append(j)
					a.append(i)
					i = idx
		print('Yes')
		print(*a)


for _ in range(int(input())):
	N = int(input())
	A = list(input().strip())
	data = ['0']
	last = 1
	if A[1] == '0' or A[0] == '0' or A[-1] == '0':
		print('No')
	else:
		for i in range(1, N):
			if A[i + 1] == '1':
				data.append(str(last))
				last = i + 1
			else:
				data.append(str(i + 1))
		sol = ' '.join(data)
		print('Yes')
		print(sol)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[0] == '0' or s[1] == '0' or s[n] == '0':
		print('No')
	else:
		res = []
		res.append(0)
		temp = 1
		for i in range(2, len(s) - 1):
			if s[i] == '0':
				res.append(i)
			else:
				res.append(temp)
				temp = i
		res.append(temp)
		print('Yes')
		for t in res:
			print(t, end=' ')
		print()


t = int(input())
for _ in range(t):
	h = 1
	n = int(input())
	s = input()
	if s[0] == '0' or s[1] == '0' or s[n] == '0':
		print('No')
		continue
	v = []
	v.append(0)
	for i in range(2, len(s) - 1):
		if s[i] == '0':
			v.append(i)
		else:
			v.append(h)
			h = i
	v.append(h)
	print('Yes')
	print(*v, sep=' ')


for _ in range(int(input())):
	N = int(input())
	b = input()
	if b[0] == '0' or b[1] == '0' or b[-1] == '0':
		print('No')
	else:
		ans = [0 for i in range(N)]
		lf = 1
		rf = len(ans) - 1
		b = b[:-1]
		for i in range(len(b) - 1, 0, -1):
			if b[i] == '1':
				ans[rf] = i
				rf -= 1
			else:
				ans[lf] = i
				lf += 1
		print('Yes')
		print(' '.join([str(i) for i in ans]))


import sys
from math import sqrt, ceil, floor, gcd
from collections import Counter, defaultdict

def int_arr():
	return list(map(int, input().split()))

def str_arr():
	return list(map(str, input().split()))

def get_str():
	return map(str, input().split())

def get_int():
	return map(int, input().split())

def get_flo():
	return map(float, input().split())

def lcm(a, b):
	return a * b // gcd(a, b)
mod = 1000000007

def solve():
	n = int(input())
	s = list(str(input()))
	if s[0] == '0' or s[-1] == '0' or s[1] == '0':
		print('No')
	else:
		ans = [i for i in range(0, n)]
		for i in range(1, n):
			if s[i] == '0':
				(ans[i], ans[i - 1]) = (ans[i - 1], ans[i])
		print('Yes')
		print(*ans)
T = 1
T = int(input())
while T:
	solve()
	T -= 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	binary = input().rstrip()
	if binary[0] == '0' or binary[1] == '0' or binary[-1] == '0':
		print('No')
		continue
	dis = []
	all = []
	for i in range(n + 1):
		if binary[i] == '0':
			dis.append(i)
		else:
			all.append(i)
	ret = []
	last = -1
	i = 0
	while i < len(dis):
		for j in range(last + 1, dis[i] - 1):
			ret.append(j)
		ret.append(dis[i])
		last = dis[i]
		add = dis[i] - 1
		while i < len(dis) - 1 and dis[i] == dis[i + 1] - 1:
			i += 1
			ret.append(dis[i])
			last = dis[i]
		ret.append(add)
		i += 1
	for i in range(last + 1, n):
		ret.append(i)
	print('Yes')
	for i in ret:
		print(i, end=' ')
	print()


try:
	for _ in range(int(input())):
		n = int(input())
		l = input()
		k = []
		if l[0] == '0' or l[1] == '0':
			print('No')
		elif l[len(l) - 1] == '0':
			print('No')
		else:
			for i in range(n):
				k.append(i)
			for i in range(n):
				if l[i] == '0':
					temp = k[i - 1]
					k[i - 1] = k[i]
					k[i] = temp
			print('Yes')
			for i in range(len(k)):
				print(k[i], end=' ')
			print()
except:
	pass


t = int(input())
while t:
	n = int(input())
	s = input()
	if s[0] == '0' or s[1] == '0':
		print('No')
	elif s[-1] == '0':
		print('No')
	else:
		lst = []
		for i in range(0, n):
			if s[i] == '1':
				lst.append(i)
			else:
				x = lst[-1]
				lst.pop()
				lst.append(i)
				lst.append(x)
		print('Yes')
		print(*lst)
	t = t - 1


for t in range(int(input())):
	n = int(input())
	s = input()
	if n == 1:
		if s[0] == '0':
			print('No')
		else:
			print('Yes')
			print(0)
		continue
	if n == 2:
		if s[0] == '0' or s[1] == '0':
			print('No')
		else:
			print('Yes')
			print('0 1')
		continue
	if s[0] == '0' or s[1] == '0' or s[-1] == '0':
		print('No')
		continue
	arr = []
	arr.append(0)
	cnt = 1
	for i in range(2, len(s) - 1):
		if s[i] == '0':
			arr.append(i)
		else:
			arr.append(cnt)
			cnt = i
	print('Yes')
	for i in arr:
		print(i, end=' ')
	print(cnt)


def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
mod = 10 ** 4
ans = 0

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count
from collections import defaultdict
import math
for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[0] != '1' or s[1] != '1':
		print('No')
		continue
	if s.count('0') == 0:
		print('Yes')
		ans = [i for i in range(n)]
		print(*ans)
		continue
	ind = s.index('0')
	ans = []
	for (i, ele) in enumerate(s):
		if i < ind - 1:
			ans.append(i)
		else:
			break
	for (i, ele) in enumerate(s):
		if ele == '0':
			ans.append(i)
	for i in range(ind - 1, len(s)):
		if s[i] == '1':
			ans.append(i)
	ans = ans[:-1]
	tot = sum(ans)
	if tot != n * (n - 1) // 2:
		print('No')
	else:
		print('Yes')
		print(*ans)