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 int long long
const int mod = 1e9+7;

int power(int a,int b){
    int res = 1;
    while(b){
        if(b&1LL)res = (res*a)%mod;
        a = (a*a)%mod;
        b/=2LL;
    }
    return res;
}

int fermat(int a){
    return power(a,mod-2);
}

int reqd(int c,int k){
    return (k-c%k)%k;
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int T = 1;
    cin>>T;

    while(T--){ 
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        if(n%k){
            cout<<"-1\n";
            continue;
        }
        int cnt[26] = {0},sum = 0;
        for(char c:s)cnt[c-'a']++;
        for(int i = 0;i<26;i++){
            sum += reqd(cnt[i],k);
        }
        if(sum == 0){cout<<s<<"\n";continue;}
        int flag = 0;
        for(int i = n-1;flag==0&&i>=0;i--){
            sum -= reqd(cnt[s[i]-'a'],k);
            cnt[s[i]-'a']--;
            sum += reqd(cnt[s[i]-'a'],k);
            for(int j = s[i]-'a'+1;j<26;j++){
                int dum = sum;
                sum -= reqd(cnt[j],k);
                cnt[j]++;
                sum += reqd(cnt[j],k);
                if(sum+i+1<=n){
                    cout<<s.substr(0,i);
                    cout<<(char)('a'+j);
                    string ans = "";
                    for(char kk = 'a';kk<='z';kk++){
                        int val = reqd(cnt[kk-'a'],k);
                        while(val--)ans+=kk;
                    }
                    // cout<<ans<<" ";
                    while((int)ans.size()+i+1<n)ans+='a';
                    sort(ans.begin(),ans.end());
                    cout<<ans<<"\n";
                    flag = 1;
                    break;
                }
                cnt[j]--;
                sum = dum;
            }
        }
    }
  
    return 0;
}
