CF2192B.Flipping Binary String

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

Flipping Binary String

You are given a binary string ss of length nn. You can perform the following operation on the string:

  • Choose an index ii, and flip the bit present at all other indices except for the index ii. In other words, choose an integer ii (1in1 \le i \le n), and for all jj such that 1jn1 \le j \le n and jij \ne i, if sj=0s_j = 0, then set sj:=1s_j:=1, otherwise set sj:=0s_j:=0.

You can perform the operation any number of times, but each index can be chosen by at most one operation.

Your task is to make all bits present in the string ss equal 00, or report that it is impossible to do so. You don't have to minimize the number of operations.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5).

The second line of each test case contains the binary string ss of length nn.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output 1-1 if it is impossible to transform all bits to 00. Otherwise, output two lines in the following format:

  • In the first line, print the number of operations xx (0xn0 \leq x \leq n).
  • In the second line of each test case, print xx numbers – the indices you select in each operation in order. You should guarantee that each index is chosen at most once.

If there are multiple possible solutions, you may output any.

Note

In the first test case, performing the operation on index 22 means flipping bits present at index 11 and 33. So the new string formed will be 000000.

In the second test case, it can be shown that we cannot make string aa equal to 000000 using the described operations.

Samples

4
3
101
3
100
4
0000
4
1010
1
2 
-1
0
2
1 3 

在线编程 IDE

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