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 find(equal):
  used=0
  dic = {}
  index=0
  upper=0
  r=""
  while index<n and used<v:
    if not upper and not equal and used==v-1:  
      char = chr(ord(s[index])+1)
      if (s[index] not in dic or dic[s[index]]%k==0):
        if s[index]=='z':
          r=r[:-1]
          dic[s[index-1]]-=1
          if dic[s[index-1]]%k==0:
            used-=1
          char = chr(ord(s[index-1])+1)
          index-=1
        if char in dic:
          dic[char]+=1
        else:
          dic[char]=1
        used+=dic[char]%k==1 or dic[char]==1
        r+=char
        upper=1
      else:
        dic[s[index]]+=1
        r+=s[index]
    else:
      if s[index] not in dic:
        dic[s[index]]=1
      else:
        dic[s[index]]+=1
      used+=dic[s[index]]%k==1 or dic[s[index]]==1
      r+=s[index]
    index+=1
  srt = sorted(dic)
  if not equal:
    for i in srt:
      while dic[i]%k!=0:
        dic[i]+=1
        r+=i
  else:
     while index<=n:
       test=0
       for i in srt:
         if dic[i]%k!=0 and i>=s[index]:
           dic[i]+=1
           r+=i
           index+=1
           test=1
           break
       if test==0:
         break
    
  return r
  
T = int(input())
for t in range(T):
  n,k = map(int,input().split())
  s = input()
  v=n//k
  if n%k==0:
    r = find(True)
    if r<s or len(r)!=len(s):
      r = find(False)
    print(r)
  else:
    print(-1)
  
