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
  r=""
  while used<v:
    if not equal and used==v-1:    
      if s[index] not in dic:
        used+=1
        char = chr(ord(s[index])+1)
        dic[char]=1
        r+=char
      else:
        if dic[s[index]]%k==0:
          used+=1
          char = chr(ord(s[index])+1)
          dic[char]=1
          r+=char
        else:
          dic[s[index]]+=1
          r+=s[index]
    else:
      if s[index] not in dic:
        used+=1
        dic[s[index]]=1
      else:
        dic[s[index]]+=1
        used+=dic[s[index]]%k==1
      r+=s[index]
    index+=1

  for i in sorted(dic):
    while dic[i]%k!=0:
      dic[i]+=1
      r+=i

  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:
      r = find(False)
    print(r)
  else:
    print(-1)
  
