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 optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define maxn 1000000000
#define el "\n"
#define pi acos(-1.0)
#define doshomik  cout<<fixed<<showpoint<<setprecision(15)
using namespace std;
#define lcm(a,b) (a/__gcd(a,b))*b
#define fast_io  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    fast_io;
    ll t=1;
    cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        if(n%k){
            cout<<"-1"<<el;
            continue;
        }
        s="0"+s;
        ll pre[n+1][26];
        for(ll i=0;i<=n;i++){
            for(ll j=0;j<26;j++) pre[i][j]=0;
        }
        for(ll i=1;i<=n;i++){
            pre[i][s[i]-'a']+=1;
            for(ll j=0;j<26;j++) pre[i][j]+=pre[i-1][j];
        }
        // check equal
        bool f=1;
        for(ll i=0;i<26;i++){
            if(pre[n][i]%k) f=0;
        }
        if(f){
            for(ll i=1;i<=n;i++) cout<<s[i];
            cout<<el;
            continue;
        }
        for(ll i=n;i>0;i--){
            ll baki=n-i,laagbe=0,a=s[i]-'a';
            for(ll j=0;j<26;j++){
                ll x;
                if(j==a) x=(pre[i][j]-1)%k;
                else x=pre[i][j]%k;
                //cout<<x<<" ";
                if(x) laagbe+=k-x;
            }
            //cout<<el;
            if(baki+1<laagbe) continue;
            //cout<<baki<<" "<<laagbe<<el;
            char c='0';
            for(ll j=a+1;j<26;j++){
                laagbe=0;
                for(ll l=0;l<26;l++){
                    ll x;
                    if(l==j) x=(pre[i][l]+1)%k;
                    else if(l==a) x=(pre[i][l]-1)%k;
                    else x=pre[i][l]%k;
                    if(x) laagbe+=k-x;
                    //cout<<x<<" ";
                }
                //cout<<el;
                if(baki>=laagbe){
                    c='a'+j;
                    break;
                }
            }
            if(c!='0'){
                //cout<<i<<" "<<c<<el;
                //cout<<baki<<" "<<laagbe<<el;
                string ans="",aage="";
                s[i]=c;
                for(ll j=1;j<=i;j++) aage+=s[j];
                //cout<<aage<<el;
                for(ll j=0;j<26;j++){
                    ll x;
                    if(j==c-'a') x=(pre[i][j]+1)%k;
                    else if(j==a) x=(pre[i][j]-1)%k;
                    else x=pre[i][j]%k;
                    if(x) x=k-x;
                    char add='a'+j;
                    for(ll l=0;l<x;l++) ans+=add;
                }
                for(ll j=0;j<baki-laagbe;j++) ans+="a";
                //cout<<ans<<el;
                sort(ans.begin(),ans.end());
                ans=aage+ans;
                cout<<ans<<el;
                break;
            }
        }
    }
    return 0;
}
