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,os,io
# sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w") 
t = int(input())
for _ in range(t):
    n,k = input().split(); n = int(n); k = int(k)
    s = list(input()); f = 0
    s1 = s[:]
    for i in range(n):
        s[i] = ord(s[i])-97
    freq = [[0 for i in range(26)] for j in range(n)]
    toadd = [0]*n
    for i in range(n):
        if i>0:
            for j in range(26): 
                freq[i][j]+=freq[i-1][j]
        freq[i][s[i]]+=1
        freq[i][s[i]]%=k 
    for i in range(n):
        cnt=0
        for j in range(26):
            if freq[i][j]!=0:
                cnt+=k-freq[i][j]
        toadd[i]=cnt 
    if toadd[-1]==0:
        print(''.join(s1))
        continue
    # print(toadd)
    for i in range(n-1,-1,-1):
        if i>0:
            if toadd[i-1]>n-i:
                continue
            if (n-i-toadd[i-1])%k!=0:
                continue
        freq[i][s[i]]-=1
        
        for char in range(s[i]+1,26):
            freq[i][char]+=1 ; freq[i][char]%=k
            c = 0
            for j in range(26):
                if freq[i][j]!=0:
                    c+=k-freq[i][j]       
            if c>n-i-1 or (n-i-1-c)%k!=0:
                freq[i][char]-=1 ; freq[i][char]%=k
                continue
            # print("char",char,s[i],i,c)
            ptr = n-1
            res = s[:i]
            res+=[0]*(n-len(res))
            res[i]=char
            for j in range(25,-1,-1):
                if freq[i][j]!=0:
                    x = k-freq[i][j]
                    while(x):
                        # print("ptr",ptr,j)
                        x-=1
                        res[ptr]=j
                        ptr-=1
                    
            for j in range(n):
                res[j]=chr(res[j]+97)
            f = 1
            # print("i",i)
            break
        if f==1:
            break 
    if f==1:
        print(''.join(res))
    else:
        print(-1)
            