Ashish has a binary string $s$ of length $n$ that he wants to sort in non-decreasing order.

He can perform the following operation:

Choose a subsequence of any length such that its elements are in non-increasing order. Formally, choose any $k$ such that $1 \leq k \leq n$ and any sequence of $k$ indices $1 \le i_1 \lt i_2 \lt \ldots \lt i_k \le n$ such that $s_{i_1} \ge s_{i_2} \ge \ldots \ge s_{i_k}$.

Reverse this subsequence in-place. Formally, swap $s_{i_1}$ with $s_{i_k}$, swap $s_{i_2}$ with $s_{i_{k-1}}$, $\ldots$ and swap $s_{i_{\lfloor k/2 \rfloor}}$ with $s_{i_{\lceil k/2 \rceil + 1}}$ (Here $\lfloor x \rfloor$ denotes the largest integer not exceeding $x$, and $\lceil x \rceil$ denotes the smallest integer not less than $x$)

Find the minimum number of operations required to sort the string in non-decreasing order. It can be proven that it is always possible to sort the given binary string in at most $n$ operations.


-----Input-----

The first line contains a single integer $t$ $(1 \le t \le 1000)$  — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer $n$ $(1 \le n \le 1000)$  — the length of the binary string $s$.

The second line of each test case contains a binary string $s$ of length $n$ containing only $0$s and $1$s.

It is guaranteed that the sum of $n$ over all test cases does not exceed $1000$.


-----Output-----

For each test case output the following:

The minimum number of operations $m$ in the first line ($0 \le m \le n$).

Each of the following $m$ lines should be of the form: $k$ $i_1$ $i_2$ ... $i_{k}$, where $k$ is the length and $i_1 \lt i_2 \lt ... \lt i_{k}$ are the indices of the chosen subsequence. For them the conditions from the statement must hold.


-----Examples-----

Input
3
7
0011111
5
10100
6
001000
Output
0
1
4 1 3 4 5 
1
3 3 5 6


-----Note-----

In the first test case, the binary string is already sorted in non-decreasing order.

In the second test case, we can perform the following operation:

$k = 4:$ choose the indices $\{1, 3, 4, 5\}$

$\underline{1}$ $0$ $\underline{1}$ $\underline{0}$ $\underline{0}$ $\rightarrow $ $\underline{0}$ $0$ $\underline{0}$ $\underline{1}$ $\underline{1}$

In the third test case, we can perform the following operation:

$k = 3:$ choose the indices $\{3, 5, 6\}$

$0$ $0$ $\underline{1}$ $0$ $\underline{0}$ $\underline{0}$ $\rightarrow $ $0$ $0$ $\underline{0}$ $0$ $\underline{0}$ $\underline{1}$

Difficulty: EASY

Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = 0
	r = n - 1
	left = []
	right = []
	while l < r:
		while l < n and s[l] != '1':
			l += 1
		while r >= 0 and s[r] != '0':
			r -= 1
		if l >= r:
			break
		left.append(l + 1)
		right.append(r + 1)
		l += 1
		r -= 1
	l = len(left)
	r = len(right)
	right = right[::-1]
	if l + r == 0:
		print('0')
	else:
		print('1')
		print(l + r, end=' ')
		for e in left:
			print(e, end=' ')
		for e in right:
			print(e, end=' ')
		print()


def fun(ans):
	o = []
	z = []
	i = 0
	j = len(ans) - 1
	while i < j:
		if ans[i] != '1':
			i += 1
		if ans[j] != '0':
			j -= 1
		if i < j and ans[j] == '0' and (ans[i] == '1'):
			o.append(i + 1)
			z.append(j + 1)
			i += 1
			j -= 1
	x = o + z[::-1]
	return x
for _ in range(int(input())):
	x = input()
	arr = input()
	x = fun(arr)
	if not x:
		print(0)
	else:
		print(1)
		print(len(x), end=' ')
		for i in x:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	v = 0
	op = []
	c = s.count('1')
	for i in range(n):
		if s[i] == '0' and i > n - 1 - c:
			op.append(i + 1)
			v += 1
		elif s[i] == '1' and i <= n - 1 - c:
			op.append(i + 1)
			v += 1
	if v == 0:
		print(0)
	else:
		print(1)
		print(v, end=' ')
		for i in op:
			print(i, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = 0
	for i in range(n):
		if s[i] == '0':
			a += 1
	ans = []
	for i in range(n):
		if i < a and s[i] == '1':
			ans += [i + 1]
		elif i >= a and s[i] == '0':
			ans += [i + 1]
	if len(ans) == 0:
		print(0)
	elif len(ans) > 0:
		print(1)
		print(len(ans), end=' ')
		for i in ans:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	f0 = []
	f1 = []
	for (i, x) in enumerate(s):
		if x == '0':
			f0.append(i + 1)
		else:
			f1.append(i + 1)
	f0.reverse()
	if not f0 or not f1 or f0[0] < f1[0]:
		print(0)
		continue
	print(1)
	res = []
	for i in range(min(len(f1), len(f0))):
		if f1[i] < f0[i]:
			res.append(f0[i])
			res.append(f1[i])
	print(len(res), end=' ')
	res.sort()
	for x in res:
		print(x, end=' ')
	print()


T = int(input())
while T:
	T -= 1
	n = int(input())
	s = input()
	on = 0
	zr = 0
	for i in s:
		if i == '1':
			on += 1
		else:
			zr += 1
	if ''.join(sorted(s)) == s:
		print(0)
		continue
	print(1)
	a = []
	for i in range(len(s)):
		if i < zr and s[i] == '1':
			a.append(i)
		elif s[i] == '0' and i >= zr:
			a.append(i)
	print(len(a), end=' ')
	for i in a:
		print(i + 1, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	string = input()
	zero = string.count('0')
	one = string.count('1')
	(notcorz, notcorro) = ([], [])
	for j in range(zero, n):
		if string[j] == '0':
			notcorro.append(j)
	for j in range(zero):
		if string[j] == '1':
			notcorz.append(j)
	if len(notcorz) + len(notcorro) == 0:
		print(0)
		continue
	else:
		print(1)
		print(len(notcorro) + len(notcorz), end=' ')
		for el in notcorz:
			print(el + 1, end=' ')
		for el in notcorro:
			print(el + 1, end=' ')
		print()


def solve(n, s):
	left = 0
	right = n - 1
	ans1 = []
	ans2 = []
	while left < n and right >= 0:
		while s[left] != '1':
			left += 1
			if left == n:
				return (ans1, ans2)
		while s[right] != '0':
			right -= 1
			if right == -1:
				return (ans1, ans2)
		if left < right:
			ans1.append(left + 1)
			ans2.insert(0, right + 1)
			left += 1
			right -= 1
		else:
			return (ans1, ans2)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(out, outt) = solve(n, s)
	out.extend(outt)
	if len(out) == 0:
		print(0)
	else:
		print(1)
		print(len(out), end=' ')
		for ele in out:
			print(ele, end=' ')
		print()


test = int(input())
for _ in range(test):
	n = int(input())
	s = input()
	pos = []
	(start, end) = (0, n - 1)
	while start < end:
		while start < end and s[start] != '1':
			start += 1
		while start < end and s[end] != '0':
			end -= 1
		if start < end:
			pos.append(start + 1)
			pos.append(end + 1)
			start += 1
			end -= 1
	if pos:
		pos.sort()
		print(1)
		print(len(pos), end=' ')
		for p in pos:
			print(p, end=' ')
		print()
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	one = s.count('1')
	zero = s.count('0')
	arr = []
	c = 0
	flag = 0
	for i in range(n):
		if i <= zero - 1:
			if s[i] == '1':
				arr.append(i)
				flag = 1
		elif i > zero - 1:
			if s[i] == '0':
				arr.append(i)
				flag = 1
	if flag == 0:
		print(0)
		continue
	for i in range(len(arr) // 2):
		(s[arr[i]], s[arr[len(arr) - 1 - i]]) = (s[arr[len(arr) - 1 - i]], s[arr[i]])
	print(1)
	print(len(arr), end=' ')
	for i in range(len(arr)):
		print(arr[i] + 1, end=' ')
	print()


for _ in range(int(input())):
	n = int(int(input()))
	lis = input()
	c = 0
	s1 = ''
	s = ''
	x = n - 1
	y = 0
	while x >= 0 or y <= x:
		if lis[x] == '1':
			pass
		else:
			for y1 in range(y, x):
				if lis[y1] == '0':
					pass
				else:
					c += 1
					s1 += ' ' + str(y1 + 1)
					s = str(x + 1) + ' ' + s
					y = y1 + 1
					break
		x -= 1
	if c:
		print(1)
		print(str(c * 2) + s1 + ' ' + s)
	else:
		print(c)


import sys
T = int(sys.stdin.readline())
for r in range(T):
	t = sys.stdin.readline()
	a = list(sys.stdin.readline().rstrip())
	b = sorted(a)
	count = 0
	result = []
	for i in range(len(a)):
		if a[i] != b[i]:
			result.append(i + 1)
			count += 1
	if count == 0:
		print('0')
	else:
		print('1')
		print(count, end=' ')
		for i in result:
			print(i, end=' ')
		print('')


def solve():
	n = int(input())
	s = input()
	ones = []
	prefix_sum = [0] * n
	if s[0] == '1':
		prefix_sum[0] = 1
	for i in range(n):
		if s[i] == '1':
			ones.append(i)
			prefix_sum[i] = prefix_sum[i - 1] + 1
		else:
			prefix_sum[i] = prefix_sum[i - 1]
	sub = 0
	result = []
	for i in reversed(range(n)):
		if s[i] == '0' and prefix_sum[i] - sub > 0:
			result.append(ones[sub])
			result.append(i)
			sub += 1
	result.sort()
	if len(result) == 0:
		print(0)
		return
	print(1)
	print(len(result), end=' ')
	for i in result:
		print(i + 1, end=' ')
	print()

def main():
	tt = int(input())
	for t in range(tt):
		solve()
main()


for _ in range(int(input())):
	safd = input()
	s = list(input())
	ans = []
	while s != sorted(s):
		l = []
		i = 0
		j = len(s) - 1
		while i < j:
			while i < len(s) and s[i] != '1':
				i += 1
			while j >= 0 and s[j] != '0':
				j -= 1
			if i < len(s) and s[i] == '1' and (j >= 0) and (s[j] == '0') and (i < j):
				l.append(i)
				l.append(j)
			i += 1
			j -= 1
		l = sorted(l)
		ans.append(l)
		zeros = 0
		ones = 0
		for k in l:
			if s[k] == '0':
				zeros += 1
			else:
				ones += 1
		for k in l:
			if zeros > 0:
				s[k] = '0'
				zeros -= 1
			else:
				s[k] = '1'
				ones -= 1
	print(len(ans))
	for g in ans:
		print(len(g), end=' ')
		for t in g:
			print(t + 1, end=' ')
		print()


n = int(input())
for i in range(n):
	m = int(input())
	s = input()
	ones = []
	for j in range(m):
		if s[j] == '1':
			ones.append(j)
	zeros = []
	for j in range(len(ones)):
		if s[m - 1 - j] == '0':
			zeros.append(m - 1 - j)
		else:
			ones.remove(m - 1 - j)
	l = ones + zeros
	if len(l):
		print(1)
		print(len(l), end=' ')
		l.sort()
		for i in range(len(l)):
			print(l[i] + 1, end=' ')
		print()
	else:
		print(0)


def revSort(string):
	ans = []
	n = len(string)
	l = []
	for x in string:
		l.append(int(x))
	m = sorted(l)
	if l == m:
		return 0
	else:
		for x in range(n):
			if l[x] != m[x]:
				ans.append(x + 1)
	return [len(ans)] + ans
t = int(input())
final = []
for _ in range(t):
	n = int(input())
	string = input()
	a = revSort(string)
	if a == 0:
		final.append(0)
	else:
		final.append(1)
		final.append(a)
for _ in range(len(final)):
	p = final[_]
	if type(p) == list:
		for x in p:
			print(x, end=' ')
		print()
	else:
		print(p)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = str(input())
	b = list(a)
	m = 0
	for x in b:
		m += '1' == x
	m = n - m
	res = []
	for i in range(n):
		if i < m:
			if b[i] == '1':
				res.append(i)
		elif b[i] == '0':
			res.append(i)
	if len(res) == 0:
		print(0)
		continue
	print(1)
	print(len(res), end=' ')
	for x in res:
		print(x + 1, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	string = input()
	ans = []
	low = 0
	high = n - 1
	cnt = 0
	while low <= high:
		if string[low] == '1':
			while string[high] == '1' and high > low:
				high -= 1
			if string[high] == '0':
				ans.append(low + 1)
				ans.append(high + 1)
				high -= 1
				cnt += 2
		low += 1
	if ans == []:
		print(0)
	else:
		print(1)
		print(cnt, end=' ')
		for j in range(0, cnt, 2):
			print(ans[j], end=' ')
		for j in range(cnt - 1, -1, -2):
			print(ans[j], end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(input())
	c = sorted(a)
	ans = 0
	one = a.count('1')
	two = a.count('0')
	ck = []
	for j in range(n - 1):
		if a == c:
			break
		ans += 1
		now = 0
		rep = []
		for i in range(n - one, n):
			if a[i] == '0':
				rep.append(i)
				now += 1
		ll = now
		for i in range(two):
			if a[i] == '1':
				rep.append(i)
				ll -= 1
		rep.sort()
		ck.append(rep)
		for i in range(len(rep) // 2):
			(a[rep[i]], a[rep[len(rep) - i - 1]]) = (a[rep[len(rep) - i - 1]], a[rep[i]])
	print(ans)
	for i in ck:
		print(len(i), end=' ')
		for j in i:
			print(j + 1, end=' ')
		print()


t = int(input())
for tc in range(t):
	n = int(input())
	ch = str(input())
	ct1 = 0
	for i in range(n):
		if ch[i] == '1':
			ct1 = ct1 + 1
	ct0 = 0
	ls = list()
	for i in range(ct1):
		if ch[n - i - 1] == '0':
			ct0 = ct0 + 1
			ls.append(n - i)
	if ct0 == 0:
		print(0)
	else:
		print(1)
		print(ct0 * 2, end=' ')
		ls.reverse()
		lp = ct0
		j = 0
		while lp > 0:
			if ch[j] == '1':
				print(j + 1, end=' ')
				lp = lp - 1
			j = j + 1
		for i in range(ct0):
			print(ls[i], end=' ')
		print()


x = int(input())
for t in range(x):
	n = int(input())
	s = input()
	ls = sorted(s)
	ans = []
	for i in range(len(ls)):
		if s[i] != ls[i]:
			ans.append(i + 1)
	if len(ans) == 0:
		print(0)
	else:
		print(1)
		print(len(ans), end=' ')
		for i in ans:
			print(i, end=' ')
		print()


import collections
import math
t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	s1 = []
	(left, right) = (0, n - 1)
	move = 1
	while left <= right:
		if s[left] == '1' and s[right] == '0':
			s1.append(left)
			s1.append(right)
			left += 1
			right -= 1
		elif s[left] == '0':
			left += 1
		elif s[right] == '1':
			right -= 1
	if len(s1) == 0:
		print(0)
	else:
		s1.sort()
		print(move)
		print(len(s1), end=' ')
		for i in s1:
			print(i + 1, end=' ')
		print('\r')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	l = list(s)
	l1 = sorted(l)
	if l == l1:
		print(0)
	else:
		k = []
		for i in range(n):
			if s[i] != l1[i]:
				k.append(i + 1)
		k.insert(0, len(k))
		print(1)
		for i in range(len(k)):
			print(k[i], end=' ')
		print()


cases = int(input())
while cases > 0:
	n = int(input())
	p = list(input())
	t = p.copy()
	tot = 0
	count1 = p.count('1')
	for i in reversed(range(0, n)):
		if p[i] == '0' and n - count1 <= i:
			t[i] = '1'
			tot += 2
		elif p[i] == '1' and n - count1 > i:
			t[i] = '0'
	if p == t:
		print(0)
	else:
		print(1)
		print(tot, end=' ')
		for i in range(n):
			if p[i] != t[i]:
				print(i + 1, end=' ')
		print()
	cases -= 1


import sys
input = sys.stdin.readline

def check(S):
	last_0 = -1
	already = 0
	first_1 = 0
	for (i, x) in enumerate(S):
		if x == '0':
			last_0 = i
		elif already == 1:
			continue
		else:
			first_1 = i
			already = 1
	return last_0 < first_1
T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	if check(s):
		print(0)
	else:
		zero_index = n - 1
		one_index = 0
		onehalf = []
		zerohalf = []
		while one_index < zero_index:
			while one_index < n and s[one_index] != '1':
				one_index += 1
			while zero_index >= 0 and s[zero_index] != '0':
				zero_index -= 1
			if one_index >= zero_index:
				break
			onehalf.append(one_index + 1)
			zerohalf.append(zero_index + 1)
			one_index += 1
			zero_index -= 1
		print(1)
		print(len(onehalf) + len(zerohalf), end=' ')
		for x in onehalf:
			print(x, end=' ')
		for x in reversed(zerohalf):
			print(x, end=' ')
		print()


import math
t = int(input())
while t > 0:
	n = int(input())
	k = [int(x) for x in input()]
	i = 0
	j = n - 1
	l = []
	while i < j:
		if k[i] == 0:
			i = i + 1
		elif k[j] == 1:
			j = j - 1
		else:
			l.append([i, j])
			i = i + 1
			j = j - 1
	if len(l) > 0:
		print(1)
		print(len(l * 2), end=' ')
		for i in l:
			print(i[0] + 1, end=' ')
		for i in l[::-1]:
			print(i[1] + 1, end=' ')
		print()
	else:
		print(0)
	t = t - 1