#P8471. [Aya Round 1 F] 琪露诺的选择题
[Aya Round 1 F] 琪露诺的选择题
Background
After some training by Shameimaru Aya, Cirno’s IQ finally increased by ⑨ points.
Now the terakoya is going to have another exam. Cirno used some methods to learn part of the information about the correct answers. Also, because she is “ice-smart”, she does not want her score improvement to be too obvious, so that the teacher, Kamishirasawa Keine, will pay special attention to her. Therefore, she came to you for help.
(Note: cheating in exams is wrong!)
Problem Description
There are multiple-choice questions, and each question has two options: and . The correct answers can be represented as a string of length .
Now you need to construct an answer sheet (also a string of length ) such that it contains exactly ’s, and compared with the correct answer string, your answer sheet has exactly wrong answers. If no such construction exists, report that there is no solution.
Note: For easier handling, this problem guarantees .
Formally, given and a binary string of length , you need to construct a binary string of length that contains exactly characters equal to , such that
where denotes the Iverson Bracket. See the “Hint” in “Notes / Hints”.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
- The first line contains three integers .
- The second line contains a string of length , representing the answer string.
Output Format
Output a total of lines.
For each test case:
- If there is a solution, output one line containing a string of length , representing the answer sheet you constructed.
- If there is no solution, output one line containing the string .
2
3 2 3
ABABBA
3 3 1
AAABBB
BBAABB
-1
Hint
Sample Explanation
For test case , the answer sheet you construct, , contains exactly ’s, and compared with the correct answer string it differs at exactly positions (i.e., there are wrong answers):
$$\text{{\color{e74c3c}A}BA{\color{e74c3c}B}B{\color{e74c3c}A}}\\ \text{{\color{52c41a}B}BA{\color{52c41a}A}B{\color{52c41a}B}}$$So it satisfies the requirements.
For test case , there is no valid construction.
Constraints
For of the data, , , , .
Within a single test file, it is guaranteed that .
Hint
The Iverson Bracket is a notation using square brackets: if the condition inside the brackets is true, it equals ; otherwise it equals . More precisely,
$$[P]=\begin{cases}1, & \text{If }P\text{ is true,}\\0,&\text{Otherwise.}\end{cases}$$Translated by ChatGPT 5