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

'''Author- Akshit Monga'''
from sys import stdin,stdout
input = stdin.readline
t = int(input())
for _ in range(t):
    n,k=map(int,input().split())
    s=input().strip()
    if n%k:
        print(-1)
        continue
    vals=[0 for i in range(26)]
    for i in s:
        vals[ord(i)-97]+=1
    for i in vals:
        if i%k:
            break
    else:
        print(s)
        continue
    distinct=n//k
    ans=[0 for i in range(n)]
    pre=[[0 for i in range(26)] for j in range(n)]
    for i in range(26):
        for j in range(n):
            if j==0:
                if ord(s[j])-97==i:
                    pre[j][i]=1
                else:
                    pre[j][i]=0
            else:
                if ord(s[j])-97==i:
                    pre[j][i]=pre[j-1][i]+1
                else:
                    pre[j][i]=pre[j-1][i]

    for i in range(n-1,-1,-1):
        #changing the ith char
        if ord(s[i])-97==25:
            continue
        req=0
        last=0
        to_add={}
        for j in range(26):
            if i==0:
                count=0
            else:
                count=pre[i-1][j]
            if count%k==0:
                continue
            else:
                req+=k-count%k
                last=j
                to_add[j]=k-count%k
        left=n-i
        if req>left:
            continue
        if req==left and last<=ord(s[i])-97:
            continue
        new=left-req
        if new%k:
            continue
        for j in range(0,i):
            ans[j]=s[j]
        if new==0:
            for j in sorted(to_add):
                if j>ord(s[i])-97:
                    ans[i]=chr(j+97)
                    to_add[j]-=1
                    break
            counter=i
            for j in sorted(to_add):
                for q in range(to_add[j]):
                    counter+=1
                    ans[counter]=chr(j+97)
        else:
            pivot=chr(ord(s[i])+1)
            ans[i]=pivot
            if ord(pivot)-97 in to_add:
                to_add[ord(pivot)-97]-=1
                to_add[0]=to_add.get(0,0)+new
            else:
                if 1%k==0:
                    var=0
                else:
                    var=k-(1%k)
                to_add[ord(pivot)-97]=var
                to_add[0]=to_add.get(0,0)+new-var-1
            counter=i
            for j in sorted(to_add):
                for q in range(to_add[j]):
                    counter+=1
                    ans[counter]=chr(j+97)
        break
    print(''.join(ans))