#P9566. [SDCPC 2023] Difficult Constructive Problem
[SDCPC 2023] Difficult Constructive Problem
题目描述
Given a string of length where and an integer , please fill out all the with or such that the number of indices satisfying and equals to . Different can be replaced with different characters.
To make this problem even more difficult, we ask you to find the answer with the smallest possible lexicographic order if it exists.
Recall that a string of length is lexicographically smaller than another string of length if there exists an integer () such that for all and .
输入格式
There are multiple test cases. The first line of the input contains an integer indicating the number of test cases. For each test case:
The first line contains two integers and (, ) indicating the length of the string and the required number of indices satisfying the condition.
The second line contains a string ().
It's guaranteed that the sum of of all test cases will not exceed .
输出格式
For each test case output one line. If the answer exists output the lexicographically smallest one (you need to output the whole given string after filling out all the  and make this string the lexicographically smallest); Otherwise output Impossible.
5
9 6
1?010??01
9 5
1?010??01
9 6
100101101
9 5
100101101
9 3
????????1
100100101
Impossible
100101101
Impossible
000000101
