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 maxn = 5e5 + 555;

char str[maxn];

map<char, int>cnt;
int n, k;

inline int cal(char c) {
    return (k - (cnt[c] % k)) % k;
}
void solve() {
    cnt.clear();
    scanf("%d %d", &n, &k);
    scanf("%s", str + 1);
    int tot = 0;
    if (n % k) {
        puts("-1");
        return;
    }

    int pos = 0;
    char posc = 'a';
    for (int i = 1; i <= n; i++) {
        int le = n - i;
        for (char nowc = str[i] + 1; nowc <= 'z'; nowc++) {
            tot -= cal(nowc);
            cnt[nowc]++;
            tot += cal(nowc);
            if (tot <= le) {
                if (pos < i) {
                    pos = i;
                    posc = nowc;
                }
            }
            tot -= cal(nowc);
            cnt[nowc]--;
            tot += cal(nowc);
        }
        char nowc = str[i];
        tot -= cal(nowc);
        cnt[nowc]++;
        tot += cal(nowc);
    }
    if (tot == 0) {
        printf("%s\n", str + 1);
        return;
    }

    cnt.clear();
    str[pos] = posc;
    for (int i = 1; i <= pos; i++) {
        cnt[str[i]]++;
    }
    tot = 0;
    for (char nowc = 'a'; nowc <= 'z'; nowc++) {
        tot += cal(nowc);
    }

    int more = (n - pos) - tot;
    for (int i = 1; i <= more; i++)
        str[i + pos] = 'a';
    char cc = 'a';

    for (int i = more + pos + 1; i <= n; i++) {
        while (cal(cc) == 0)
            cc++;
        str[i] = cc;
        cnt[cc]++;
    }
    printf("%s\n", str + 1);
}

signed main() {
    //freopen("in.txt", "r", stdin);
    int T = 1;
    cin >> T;
    while (T--)
        solve();
}
