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
for _ in range(int(input())):
    n,k=[int(x) for x in input().split()]
    s=input()
    if n%k:
        print(-1)
        continue
    temp=[0 for i in range(26)]
    for i in s:
        temp[ord(i)-ord('a')]+=1
    f=True
    for i in temp:
        if i%k:
            f=False
    if f:
        print(s)
        continue
    for i in range(n-1,-1,-1):
        temp[ord(s[i])-ord('a')]-=1
        f=False
        for j in range(ord(s[i])+1-ord('a'),26):
            temp[j]+=1
            curr=0
            for p in range(26):
                if temp[p]%k:
                    curr+=(k-temp[p]%k)
            if curr==n-1-i:
                ind=i
                now=j
                f=True
                break
            temp[j]-=1
        if f:
            break
    for i in range(26):
        if temp[i]%k:
            temp[i]+=(k-temp[i]%k)
    ans=s[:ind]+chr(ord('a')+j)
    for i in s[:ind]:
        temp[ord(i)-ord('a')]-=1
    temp[j]-=1
    #print(j)
    #print(temp)
    for i in range(26):
        ans+=temp[i]*chr(ord('a')+i)
    print(ans)