#P7814. 「小窝 R3」心の記憶
「小窝 R3」心の記憶
Background
The pale dusk was swallowed up.
I ran as if to make you forget.
Your fading figure.
Into a new peaceful world.
——Heart no Kioku
Problem Description
- In this problem, the definition of a "substring" is as follows:
A substring of a string is a string formed by any number of consecutive characters in . A substring of can be represented by a starting position and an ending position , denoted as (, where denotes the length of ).
- In this problem, the definition of a "subsequence" is as follows:
For a string and a strictly increasing sequence of length , $k_1,k_2,\cdots,k_n(\forall 1\le i\le n,1\le k_i\le |S|)$, the string formed by is a subsequence of .
There are queries. In each query, you are given a binary string of length , denoted as . Your answer should be a string such that:
- is a binary string of length .
- There does not exist any substring in that is equal to .
- There exists at least one subsequence in that is equal to .
You may output any string that satisfies the requirements.
Input Format
The first line contains one positive integer , indicating the number of queries.
For each query, the first line contains two positive integers (), representing the lengths of the binary strings .
The second line contains a binary string of length .
Output Format
Output lines in total. Each line contains a binary string of length . If there is no solution, output -1.
4
1 1
1
3 5
010
4 8
1101
5 6
11111
-1
01110
10100101
111101
Hint
Sample Explanation
In the second query, 01101 and 10110 are also valid solutions.
Constraints
| Subtask | Score | Special Property | |
|---|---|---|---|
consists only of 0 |
|||
| None | |||
| is generated randomly | |||
| None |
For of the testdata, , . It is guaranteed that consists only of 0 and 1.
Translated by ChatGPT 5