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

def charToInt(c): #'a'->0
    return ord(c)-ord('a')
def intToChar(x): #0->'a'
    return chr(ord('a')+x)

def main():
    
    t=int(input())
    allans=[]
    for _ in range(t):
        n,k=readIntArr()
        s=input()
        if n%k!=0:
            allans.append(-1)
            continue
        
        sarr=[charToInt(c) for c in s]
        ansarr=[None for _ in range(n)]
        
        remaining=[0 for _ in range(26)] # in batches of k
        totalremaining=0
        
        def checkCanComplete(i,val): # check if by putting val at idx i, it's possible to complete
            if val>25:
                return False
            actualRemaining=n-i-1
            if remaining[val]>0: # can take from totalremaining
                newtotalremaining=totalremaining-1
            else:
                newtotalremaining=totalremaining-1+k
            if newtotalremaining>actualRemaining:
                return False
            else:
                return True
        
        ok=True
        for i in range(n):
            if checkCanComplete(i,sarr[i]):
                ansarr[i]=sarr[i]
                remaining[sarr[i]]-=1
                totalremaining-=1
                if remaining[sarr[i]]<0:
                    remaining[sarr[i]]+=k
                    totalremaining+=k
            else:
                ok=False
                break
        if ok==False:
            # print('ansarr:{} remaining:{} totalremining:{} i:{}'.format(ansarr,remaining,totalremaining,i))
            j=i
            while True:
                # print('ansarr:{} remaining:{} j:{}'.format(ansarr,remaining,j))
                if ansarr[j]!=None: # need to reverse the counts
                        # print('reverse j:{}'.format(j))
                        ansarr[j]=None
                        remaining[sarr[j]]+=1
                        totalremaining+=1
                        if remaining[sarr[j]]==k:
                            remaining[sarr[j]]-=k
                            totalremaining-=k
                ok=False
                for z in range(sarr[j]+1,26):
                    if checkCanComplete(j,z):
                        ansarr[j]=z
                        remaining[z]-=1
                        totalremaining-=1
                        if remaining[z]<0:
                            remaining[z]+=k
                            totalremaining+=k
                        j+=1
                        ok=True
                        break
                if ok:
                    break
                j-=1
            
            # print('ansarr:{} j:{} remaining:{} totalRemaining:{}'.format(ansarr,j,remaining,totalremaining))
            
            #fill with 0s then the remaining
            while j<n:
                actualRemaining=n-j
                if actualRemaining>totalremaining: # fill with 0s
                    ansarr[j]=0
                    j+=1
                else:
                    for i in range(26):
                        for __ in range(remaining[i]):
                            ansarr[j]=i
                            j+=1
                            totalremaining-=1
        ans=''.join([intToChar(x) for x in ansarr])
        allans.append(ans)
    multiLineArrayPrint(allans)
        
    return
    
import sys
# input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.
 
def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
    print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
    print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
 
def readIntArr():
    return [int(x) for x in input().split()]
# def readFloatArr():
#     return [float(x) for x in input().split()]

def makeArr(defaultVal,dimensionArr): # eg. makeArr(0,[n,m])
    dv=defaultVal;da=dimensionArr
    if len(da)==1:return [dv for _ in range(da[0])]
    else:return [makeArr(dv,da[1:]) for _ in range(da[0])]
 
def queryInteractive(x,y):
    print('? {} {}'.format(x,y))
    sys.stdout.flush()
    return int(input())
 
def answerInteractive(ans):
    print('! {}'.format(ans))
    sys.stdout.flush()
 
inf=float('inf')
MOD=10**9+7
 
 
for _abc in range(1):
    main()