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>

#define inp 50005
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }

using namespace std;

int main()
{
    jaldi

    int t;
    cin>>t;

    while(t--)
    {
        int n,k;
        cin>>n>>k;

        string s;
        cin>>s;

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

        string ans = "";
        vector<int> v(26);
        for(char c : s) v[c-'a']++;

        bool ok = true;
        for(int i=0;i<26;i++)
        {
            ok &= !(v[i] % k);
        }

        if(ok) { cout << s << "\n"; continue; }

        for(int i=n-1;i>=0 && ans=="";i--)
        {
            v[s[i]-'a']--;
            // deb(v);
            for(char c=s[i]+1;c<='z';c++)
            {
                bool done = true;
                v[c-'a']++;

                int space = n - i - 1;
                for(int j=0;j<26;j++)
                {
                    if(v[j] % k)
                    {
                        int req = k - (v[j] % k);
                        if(req <= space) { space -= req; continue; }
                        done = false;
                        break;
                    }
                }

                if(done)
                {
                    for(int j=0;j<i;j++) ans += s[j];
                    ans += c;

                    int pachal = 0;
                    for(int i=0;i<26;i++)
                    {
                        if(v[i] % k)
                        {
                            int req = k - (v[i] % k);
                            pachal += req;
                        }
                    }

                    int vadhya = n - ans.size() - pachal;
                    while(vadhya--) ans += 'a';

                    for(int i=0;i<26;i++)
                    {
                        if(v[i] % k)
                        {
                            int req = k - (v[i] % k);
                            while(req--) ans += char(i+'a');
                        }
                    }

                    break;
                }

                v[c-'a']--;
            }
        }
        cout << ans << "\n";
    }

    return 0;
}