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

//cyc
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define vector<int> VI
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mst(a) memset(a,0,sizeof a)

using namespace std;
typedef pair<int,int> pii;
int vis[27];
int vec[27];
int cal(int x,int k){return (k-(x%k))%k;}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int _;
    cin>>_;
    while(_--){
        mst(vis);
        int n,k;
        cin>>n>>k;
        string s1;
        cin>>s1;
        int sum=0;
        for(int i=0;i<n;i++)vis[s1[i]-'a']++;
        for(int i=0;i<26;i++){
            sum+=cal(vis[i],k);
        }
        if(sum==0)cout<<s1<<endl;
        else if(sum%k)cout<<-1<<endl;
        else {
            int prev;
            for(int i=n-1;i>=0;i--){
                int flag=0;
                sum=sum-cal(vis[s1[i]-'a'],k);
                vis[s1[i]-'a']--;
                sum+=cal(vis[s1[i]-'a'],k);
                prev=sum;
                for(int j=s1[i]-'a'+1;j<26;j++){

                    sum-=cal(vis[j],k);
                    vis[j]++;
                    sum+=cal(vis[j],k);
                    if(i+1+sum<=n){
                        for(int p=0;p<i;p++)cout<<s1[p];
                        cout<<char('a'+j);
                        for(int p=1;p<n-sum-i;p++)cout<<"a";
                        for(int p=0;p<26;p++){
                            int z=cal(vis[p],k);
                            if(z>0){
                                for(int q=1;q<=z;q++)cout<<char('a'+p);
                            }
                        }
                        cout<<endl;
                        flag=1;
                        break;
                    }

                    sum=prev;
                    vis[j]--;
                }
                if(flag)break;
            }
        }
    }
}
