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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int>,null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update> order_set;
#define fir first
#define sec second
#define pb push_back
#define ll long long
#define sz size
#define mp make_pair
#define en "\n"
#define victor vector
#define ld long double
//#define int128 __int128
void solve()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (n % k != 0)
    {
        cout << -1 << en;
        return;
    }
    int a[26];
    for (int i = 0; i < 26; i++)
        a[i] = 0;
    for (int i = 0; i < s.sz(); i++)
        a[s[i]-'a']++;
    for (int i = 0; i < 26; i++)
        if (a[i] % k != 0)
            break;
        else if (i == 25)
        {
            cout << s << en;
            return;
        }
    int pref[26][n];
    for (int i = 0; i < 26; i++)
        for (int j = 0; j < n; j++)
            pref[i][j] = 0;
    for (int i = 0; i < n; i++)
    {
        pref[s[i]-'a'][i]++;
        if (i > 0)
            for (int j = 0; j < 26; j++)
                pref[j][i] += pref[j][i-1];
    }
    string ans;
    for (int i = 0; i < n; i++)
        ans += 'z';
    for (int i = 0; i < 26; i++)
    {
        for (int j = n-1; j >= 0; j--)
            if (i > s[j]-'a')
            {
                pref[s[j]-'a'][j]--;
                pref[i][j]++;
                int sum = 0;
                for (int v = 0; v < 26; v++)
                    sum += (k-pref[v][j]) % k;
                if (sum > n-j-1)
                {
                    pref[s[j]-'a'][j]++;
                    pref[i][j]--;
                    continue;
                }
                string p, now;
                for (int v = 0; v < 26; v++)
                    for (int u = 0; u < (k-pref[v][j]) % k; u++)
                        p += char('a'+v);
                while (p.sz()+j+1 < n)
                    p += 'a';
                sort(p.begin(), p.end());
                for (int v = 0; v < j; v++)
                    now += s[v];
                now += char('a'+i);
                now += p;
                ans = min(ans, now);
                pref[s[j]-'a'][j]++;
                pref[i][j]--;
                break;
            }
    }
    cout << ans << en;
}
int main()
{
    //freopen("input10.txt", "r", stdin);
    //freopen("output10.txt", "w", stdout);
    ios::sync_with_stdio(0);
    int q;
    cin >> q;
    while (q--)
        solve();
}
