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

import sys
input = sys.stdin.readline

t=int(input())
for tests in range(t):
    n,k=map(int,input().split())
    S=list(input().strip())
    SA=S[:]+["z"]

    COUNT=[[0]*26 for i in range(n)]

    for i in range(n):
        for j in range(26):
            COUNT[i][j]=COUNT[i-1][j]
        COUNT[i][ord(S[i])-97]+=1

    ANS=-1

    for i in range(n-1,-1,-1):
        SA.pop()
        amari=0
        
        for j in range(26):
            amari+=((k-COUNT[i][j])%k)
            if amari>n-1-i:
                break
            
        else:
            if (n-1-i-amari)%k==0:
                alist=[]
                for j in range(26):
                    alist+=[chr(j+97)]*((k-COUNT[i][j])%k)

                #print(S,"!",SA,alist)

                #zlist=alist+["z"]*(n-1-i-amari)
                #zlist.sort(reverse=True)

                #ss="".join(zlist)
                #print(S[:i+1],ss)
                #if S[:i+1]+ss<S:
                #    continue

                if i==len(S)-1:
                    ANS=S
                    print("".join(ANS))
                    break

                if len(S)==i+1+len(alist):
                    alist.sort()
                    for xx in alist:
                        if xx>S[i+1]:
                            SSS=SA+[xx]
                            break
                    else:
                        continue

                else:
                    if S[i+1]!="z":
                        SSS=SA+[chr(ord(S[i+1])+1)]
                    else:
                        continue

                count2=[0]*26
                for s in SSS:
                    count2[ord(s)-97]+=1

                nokori=[]
                for j in range(26):
                    nokori+=[chr(j+97)]*((k-count2[j])%k)

                nokori+=["a"]*(len(S)-len(nokori)-len(SSS))
                nokori.sort()

                ANS=SSS+nokori
                if ANS>=S:
                    print("".join(ANS))
                    break

    if ANS==-1:
        if n%k==0:
            print(chr(ord(S[0])+1)*n)
        else:
            print(ANS)

                
                

                    

                
            
        

    

    
