12
12 3
zazasqzqsasq
1 1
z
1 1
a
15 4
abccbaabccbazaa
16 8
cadjfdsljfdkljds
6 2
baazaa
6 3
bosszb
6 1
qwerty
7 7
daaaaaa
14 2
acabcbdeffewzd
18 6
zzzzzzzzzzzzyyyyyz
9 4
aabaabbbc

zazasqzqsasq
z
a
-1
cbbbbbbbbccccccc
baazbz
bpbbpp
qwerty
ddddddd
acabcbdeffexdx
zzzzzzzzzzzzzzzzzz
-1

#include<bits/stdc++.h>

using namespace std;
const int N = 1e5 + 10;
char a[N];
int n, k, num[N][26], r[26], T;

inline bool check(int i, int c) {
    num[i][a[i] - 'a']--, num[i][c]++;
    memset(r, 0, sizeof(r));
    int s = 0;
    for (int j = 0; j < 26; j++) {
        if (num[i][j] % k == 0)continue;
        r[j] = k - (num[i][j] % k);
        s += r[j];
    }
    num[i][a[i] - 'a']++, num[i][c]--;
    if (n - i - s < 0 || (n - i - s) % k != 0)return false;
    for (int j = 1; j < i; j++)putchar(a[j]);
    putchar('a' + c);
    for (int j = 1; j <= n - i - s; j++)
        putchar('a');
    for (int j = 0; j < 26; j++)
        for (int l = 1; l <= r[j]; l++)putchar('a' + j);
    puts("");
    return true;
}

inline void solve() {
    scanf("%d%d%s", &n, &k, a + 1);
    if (n % k)return puts("-1"), void();
    for (int i = 1; i <= n; i++) {
        memcpy(num[i], num[i - 1], sizeof(num[i]));
        num[i][a[i] - 'a']++;
    }
    if (check(n, a[n] - 'a'))return;
    for (int i = n; i >= 1; i--)
        for (int j = a[i] - 'a' + 1; j < 26; j++)
            if (check(i, j))return;
    return puts("-1"), void();
}

int main() {
    scanf("%d", &T);
    while (T--) solve();
    return 0;
}