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
from collections import Counter

t=int(input())
for tests in range(t):
    n,k=map(int,input().split())
    S=input().strip()

    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

    #print(COUNT)

    ANS=-1

    for i in range(n-1,-1,-1):
        amari=0
        alist=[]
        for j in range(26):
            amari+=((k-COUNT[i][j])%k)
            alist+=[chr(j+97)]*((k-COUNT[i][j])%k)

            if amari>n-1-i:
                break
        else:
            if (n-1-i-amari)%k==0:
                SA=S[:i+1]
                #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

                for xx in "abcdefghijklmnopqrstuvwxyz":
                    ulist=alist+[xx]*(n-1-i-amari)
                    ulist.sort(reverse=True)

                    ss="".join(ulist)
                    if S[:i+1]+ss>=S:
                        break

                C=Counter(ss)
                ANS=S[:i+1]
                for xx in "abcdefghijklmnopqrstuvwxyz":
                    if xx>S[i] and C[xx]>0:
                        C[xx]-=1
                        ANS+=xx
                        break

                for xx in "abcdefghijklmnopqrstuvwxyz":
                    while C[xx]>0:
                        C[xx]-=1
                        ANS+=xx

                print(ANS)
                break

    if ANS==-1:
        print(ANS)

                
                

                    

                
            
        

    

    
