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 ll long long
#define ull unsigned long long
#define rep(x,a,b) for(int x=(a);x<=(b);x++)
#define per(x,a,b) for(int x=(a);x>=(b);x--)
#define scf(a) scanf("%d",&a)
#define scfll(a) scanf("%lld",&a)
#define scfdb(a) scanf("%lf",&a)
#define ptf(a) printf("%d",a)
#define ptfll(a) printf("%lld",a)
#define ptfdb(a) printf("%lf",a)
#define ptfsp(a) printf("%d ",a)
#define ptfllsp(a) printf("%lld ",a)
#define ptfdbsp(a) printf("%lf ",a)
#define pli(a,b) make_pair(a,b)
#define pb push_back
#define el puts("")
#define pi 3.1415926
using namespace std;
const int maxn=3e5+5;
const ll mod=998244353;
char s[maxn];
int c[26],d[26];
int main(){
    int T;
    scf(T);
    while(T--){
        int n,k;
        scf(n);scf(k);
        scanf("%s",s+1);
        if(n%k!=0) puts("-1");
        else{
            if(k==1){
                rep(i,1,n) printf("%c",s[i]);el;
                continue;
            }
            memset(c,0,sizeof(c));
            rep(i,1,n) c[s[i]-'a']++;
            bool flag=1;
            rep(i,0,25)
                if(c[i]%k!=0){
                    flag=0;break;
                }
            if(flag){
                rep(i,1,n) printf("%c",s[i]);el;
                continue;
            }
            flag=0;
            per(i,n,1){
                if(flag) break;
                c[s[i]-'a']--;
                rep(p,s[i]+1,'z'){
                    c[p-'a']++;
                    int resk=n-i;
                    rep(j,0,25) d[j]=0;
                    rep(j,0,25)
                        if(c[j]%k!=0){
                            d[j]=k-c[j]%k;
                            resk-=d[j];
                        }
                    if(resk<0||resk%k!=0){
                        c[p-'a']--;
                        continue;
                    }
                    flag=1;
                    d[0]+=resk;
                    s[i]=p;
                    rep(j,1,i) printf("%c",s[j]);
                    rep(j,0,25){
                        while(d[j]--) printf("%c",j+'a');
                    }
                    el;
                    break;
                }
            }
            if(!flag) puts("-1");
        }
    }
}