CF2162B.Beautiful String

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Beautiful String

You are given a binary^{\text{∗}} string ss of length nn.

Your task is to find any subsequence^{\text{†}} pp of ss such that:

  • The subsequence pp is non-decreasing. That is, each character in pp is not greater than the next one.
  • Let xx denote the string obtained by removing all characters of pp from ss, while preserving the order of the remaining characters. Then xx must be a palindrome^{\text{‡}}.

You only need to output any valid subsequence pp that satisfies both conditions. If no such subsequence exists, output 1-1.

Note that an empty string is both non-decreasing and a palindrome.

^{\text{∗}}A binary string is a string consisting of characters '0' and '1'.

^{\text{†}}A subsequence of a string s=s1s2sns = s_1s_2\ldots s_n is a sequence p=si1si2sikp = s_{i_1}s_{i_2}\ldots s_{i_k} such that 1i1<i2<<ikn1 \leq i_1 \lt i_2 \lt \ldots \lt i_k \leq n. The characters are selected in order, but not necessarily contiguously. Note that an empty string is a subsequence of any string.

^{\text{‡}}A string t=t1t2tmt = t_1t_2\ldots t_m is a palindrome if ti=tmi+1t_i = t_{m - i + 1} for all 1im1 \leq i \leq m. In other words, the string reads the same forward and backward.

Input

The first line contains a single integer tt (1t30001 \le t \le 3000) — the number of test cases.

The first line of each test case contains a single integer nn (1n101 \le n \le 10) — the length of the string.

The second line contains a binary string ss of length nn.

Output

If a solution exists:

  • On the first line, print a single integer kk (0kn0 \le k \le n) — the length of the subsequence pp.
  • On the second line, print kk distinct integers i1,i2,,iki_1, i_2, \dots, i_k (1i1<i2<<ikn1 \le i_1 \lt i_2 \lt \dots \lt i_k \le n) — the indices of the characters in ss that form pp (in order as they appear in ss).

Otherwise, print a single line containing 1-1.

Note

In the first test case, we remove an empty string, resulting in x=010x = \texttt{010}, which is a palindrome.

In the second test case, we remove p=01p = \texttt{01} (indices 22, 33), resulting in x=0x = \texttt{0}, which is a palindrome.

In the third test case, we remove p=00111p = \texttt{00111} (indices 11 to 55), resulting in an empty string, which is trivially a palindrome.

In the fourth test case, we remove p=01p = \texttt{01} (indices 33, 44), resulting in x=110011x = \texttt{110011}, which is a palindrome.

In the fifth test case, we remove p=01p = \texttt{01} (indices 55, 66), resulting in x=1001x = \texttt{1001}, which is a palindrome.

Samples

5
3
010
3
001
5
00111
8
11010011
6
100101
0

2
2 3
5
1 2 3 4 5
2
3 4
2
5 6

在线编程 IDE

建议全屏模式获得最佳体验