Problem: You are given a binary string of length . You have exactly moves. In one move, you must select a single bit. The state of all bits except that bit will get flipped ( becomes , becomes ). You need to output the lexicographically largest string that you can get after using all moves. Also, output the number of times you will select each bit. If there are multiple ways to do this, you may output any of them.
A binary string is lexicographically larger than a binary string of the same length, if and only if the following holds:
- in the first position where and differ, the string contains a , and the string contains a .
Input Format: The first line contains a single integer () — the number of test cases.
Each test case has two lines. The first line has two integers and (; ).
The second line has a binary string of length , each character is either or .
The sum of over all test cases does not exceed .
Output Format: For each test case, output two lines.
The first line should contain the lexicographically largest string you can obtain.
The second line should contain integers , where is the number of times the -th bit is selected. The sum of all the integers must be equal to .
Note: Here is the explanation for the first testcase. Each step shows how the binary string changes in a move.
- Choose bit : .
- Choose bit : .
- Choose bit : .