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;

int cnt[1007], needAdd[1007];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int T; cin >> T;
    while (T--) {
        int n, k;
        cin >> n >> k;
        string s; cin >> s;

        if (n%k) {
            cout << "-1\n";
            continue;
        }

        for (int i = 0; i <= 'z'-'a'; ++i) cnt[i] = 0;
        for (int i = 0; i < n; ++i) ++cnt[s[i]-'a'];

        bool isAns = true;
        for (int i = 0; i <= 'z'-'a'; ++i) isAns &= cnt[i]%k == 0;

        if (isAns) {
            cout << s << '\n';
            continue;
        }

        string ans;
        for (int i = n-1; i >= 0; --i) {
            for (int j = s[i]-'a'+1; j <= 'z'-'a'; ++j) {
                --cnt[j-1];
                ++cnt[j];
                int res = 0;
                for (int c = 0; c <= 'z'-'a'; ++c) res += (k-cnt[c]%k)%k;
                if (res <= n-i-1 && (n-i-1-res)%k == 0) {
                    for (int idx = 0; idx < i; ++idx) ans += s[idx];
                    ans += j+'a';
                    for (int c = 0; c <= 'z'-'a'; ++c) needAdd[c] += (k-cnt[c]%k)%k;
                    needAdd[0] += n-i-1-res;
                    int curChar = 0;
                    for (int idx = i+1; idx < n; ++idx) {
                        while (!needAdd[curChar]) ++curChar;
                        ans += curChar+'a';
                        --needAdd[curChar];
                    }
                    break;
                }
            }
            --cnt['z'-'a'];
            if (!ans.empty()) break;
        }
        if (ans.empty()) cout << "-1\n";
        else cout << ans << '\n';
    }
    return 0;
}