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 <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 30;
int vis[maxn];
int dis[maxn];
int main() {
    int t;
    cin >> t;
    while (t --) {
        memset(vis, 0, sizeof(vis));
        memset(dis, 0, sizeof(dis));
        int n, k;
        string s;
        cin >> n >> k;
        cin >> s;
        if (n % k) {
            cout << "-1" << endl;
            continue;
        }
        for (int i = 0; i < s.length(); ++ i) {
            vis[s[i]-'a'] ++;
        }
        bool flag = true;
        for (int i = 0; i < 26; ++ i) {
            if (vis[i] % k) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << s << endl;
            continue;
        }



        for (int i = s.length()-1; i >= 0; -- i) {
            vis[s[i]-'a'] --;

            for (int j = s[i]-'a'+1; j < 26; ++ j) {
                vis[j] ++;

                int ans = s.length()-i-1;
                for (int f = 0; f < 26; ++ f) {
                    if (vis[f]%k) ans -= (k-(vis[f]%k));
                }
                if (ans >= 0 && ans % k == 0) {
                    for (int f = 0; f < 26; ++ f) {
                        if (vis[f] % k) dis[f] += (k-(vis[f]%k));
                        // cout << vis[f] << " " << dis[f] << endl;
                    }
                    dis[0] += ans;

                    for (int f = 0; f < i; ++ f) {
                        cout << s[f];
                    }
                    cout << char('a'+j);
                    for (int f = 0; f < 26; ++ f) {
                        while (dis[f] --) {
                            cout << char(f+'a');
                        }
                    }
                    cout << endl;
                    flag = true;
                    break;
                }
                
                if (flag) break;
                vis[j] --;
            }
            if (flag) break;
        }
    }
    return 0;
}