|
||||||||||
Square DistanceTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 721 Accepted Submission(s): 248 Problem Description A string is called a square string if it can be obtained by concatenating two copies of the same string. For example, "abab", "aa" are square strings, while "aaa", "abba" are not. Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Peter has a string $s=s_{1}s_{2}...s_{n}$ of even length. He wants to find a lexicographically smallest square string $t=t_{1}t_{2}...t_{n}$ that the hamming distance between $s$ and $t$ is exact $m$. In addition, both $s$ and $t$ should consist only of lowercase English letters. Input There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case: The first contains two integers $n$ and $m$ $(1 \le n \le 1000, 0 \le m \le n, n \text{ is even})$ -- the length of the string and the hamming distance. The second line contains the string $s$. Output For each test case, if there is no such square string, output "Impossible" (without the quotes). Otherwise, output the lexicographically smallest square string. Sample Input
Sample Output
Source | ||||||||||
|