/*头文件模板*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define pb push_back #define mp make_pair #define mem(a, x) memset(a, x, sizeof(a)) #define copy(a, b) memcpy(a, b, sizeof(a)) #define lson rt << 1, l, mid #define rson rt << 1|1, mid + 1, r #define FIN freopen("input.txt", "r", stdin) #define FOUT freopen("output.txt", "w", stdout) typedef long long LL; typedef pair PII; typedef pair PIS; typedef pairPLL; typedef unsigned long long uLL; template void print (T* p, T* q, string Gap = " ", bool flag = false) { int d = p < q ? 1 : -1; while (p != q) { if (flag) cout << Gap[0] << *p << Gap[1]; else cout << *p; p += d; if (p != q && !flag) cout << Gap; } cout << endl; } template void print (const T &a, string bes = "") { int len = bes.length(); if (len >= 2) cout << bes[0] << a << bes[1] << endl; else cout << a << endl; } template void debug (T* p, T* q, string Gap = " ", bool flag = false) { #ifndef ONLINE_JUDGE int d = p < q ? 1 : -1; cout << "Debug out : "; while (p != q) { if (flag) cout << Gap[0] << *p << Gap[1]; else cout << *p; p += d; if (p != q && !flag) cout << Gap; } cout << endl; #endif } template void debug (const T &a, string bes = "") { #ifndef ONLINE_JUDGE int len = bes.length(); cout << "Debug out : "; if (len >= 2) cout << bes[0] << a << bes[1] << endl; else cout << a << endl; #endif } void IO_Init() { ios::sync_with_stdio (false); } LL LLabs (const LL a) { return a >= 0 ? a : -a; } const double PI = 3.1415926535898; const double eps = 1e-10; const int MAXM = 1e5 + 5; const int MAXN = 1e3 + 5; const int INF = 0x3f3f3f3f; /*头文件模板*/ int T; int n, m; char S[MAXN], SF[MAXN]; int SMa[MAXN], SMi[MAXN]; char J[MAXN]; int main() { #ifndef ONLINE_JUDGE FIN; //FOUT; #endif IO_Init(); scanf("%d", &T); while(T --) { scanf("%d%d%s", &n, &m, S); int len = strlen(S); if(len & 1) { printf("Impossible\n"); continue; } SMa[len / 2] = 0; SMi[len / 2] = 0; for(int i = len / 2 - 1; i >= 0; i --) { if(S[i] != S[i + len / 2]) { SMa[i] = SMa[i + 1] + 2; SMi[i] = SMi[i + 1] + 1; } else { SMa[i] = SMa[i + 1] + 2; SMi[i] = SMi[i + 1]; } } bool flag = true; if(m > SMa[0] || m < SMi[0]) { flag = false; } int l = 0; while(l < len / 2 && flag) { int k1 = m - SMa[l + 1]; int k2 = m - SMi[l + 1]; k2 = max(0, k2); k1 = max(0, k1); char a = 'a'; while(true) { if(a > 'z') { flag = false; break; } int bt = (a != S[l] ? 1 : 0) + (a != S[l + len / 2] ? 1 : 0); if(bt >= k1 && bt <= k2) { J[l ++] = a; m -= bt; break; } a ++; } } if(!flag) { printf("Impossible\n"); continue; } for(int i = 0; i < l; i ++) { printf("%c", J[i]); } for(int i = 0; i < l; i ++) { printf("%c", J[i]); } printf("\n"); } return 0; }