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>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        if(n%k!=0){
            cout<<"-1\n";
            continue;
        }
        vector <int> ctr(26,0);
        for(int i=0;i<n;i++)
            ctr[s[i]-'a']++;
        int check=1;
        for(int i=0;i<26;i++){
            if(ctr[i]%k!=0)
                check=0;
        }
        if(check){
            cout<<s<<"\n";
            continue;
        } 
        string ans="";
        check=0;
        for(int i=n-1;i>=0&&check==0;i--){
            ctr[s[i]-'a']--;
            for(int j=s[i]-'a'+1;j<26;j++){
                ctr[j]++;
                s[i]='a'+j;
                int val=0;
                for(int g=0;g<26;g++){
                    val+=(k-ctr[g]%k)%k;
                }
                if(val<=n-i-1){
                    for(int g=0;g<=i;g++)
                        ans+=s[g];
                    string w="";
                    for(int g=0;g<26;g++){
                        if(ctr[g]%k!=0){
                            char h='a'+g;
                            w+=string(k-ctr[g]%k,h);
                        }
                    }
                    while(w.length()+ans.length()!=n){
                        w+='a';
                    }
                    sort(w.begin(),w.end());
                    ans+=w;
                    check=1;
                    break;
                }
                ctr[j]--;
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}