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 <iostream>
#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int oo = 1e5+7;
int t, n, k, pr[26], a[oo];
string s;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while (t--) {
        cin >> n >> k >> s;
        forn(i, 26) pr[i] = 0;
        forn(i, n) a[i] = s[i]-'a';
        forn(i, n) pr[a[i]]++;
        bool ans = 1;
        forn(i, 26) ans &= pr[i] % k == 0;
        if (n%k != 0) goto bad;
        if (ans) {
            cout << s << endl;
            continue;
        }
        for (int e = n-1; e >= 0; e--) {
            pr[a[e]]--;
            if (a[e]==25) continue;
            int touse = 0;
            forn(i, 26) touse += (k - pr[i] % k) % k;
            bool bad = 1;
            for (int i = a[e]+1; i < 26; i++) bad &= pr[i]%k == 0;
            if ((n - e - touse) % k == 0 && ((!bad && touse <= n - e) || touse + k <= n - e)) {
                int y = 25;
                if (touse + k <= n - e) {
                    // pr[a[e]+1] += k;
                    s[e] = a[e]+1+'a';
                    pr[a[e]+1]++;
                } else {
                    int out = -1;
                    for (int i = a[e] + 1; i < 26; i++) if (pr[i]%k) {out = i; break;}
                    if (out==-1) throw 69;
                    s[e] = out+'a';
                    pr[out]++;
                }
                /*
                int m;
                if (to) {
                    m = a[e]+1;
                    pr[m] += k;
                }
                for (m = a[e]+1; m < 26; m++) {

                    if (true) {
                        break;
                    }
                }
                s[e] = m+'a';
                pr[m]--;
                */
                for (int c = n-1; c >= e+1; c--) {
                    while (y > 0 && pr[y]%k==0) y--;
                    s[c] = y + 'a';
                    pr[y]++;
                }
                cout << s << endl;
                goto end;
            }
        }
        bad:
        cout << -1 << endl;
        end: {}
    }
}