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

t = int(input())

def convert(a):
  n = len(a)
  result = ['*' for _ in range(n)]
  for i in range(n):
    result[i] = chr(a[i] + ord('a'))
  return ''.join(result)

for _iterator_ in range(t):
  n, k = list(map(int, input().split()))
  s = list(map(ord, list(input())))
 
  if n % k:
    print(-1)
    continue

  for i in range(n):
    s[i] -= ord('a')
    
  convertedS = convert(s)
  arr = [[] for _ in range(25)]

  for i in range(n):
    if s[i] != 25:
      arr[s[i]].append(i)
  
  good = True
  for indexes in arr:
    good &= len(indexes) % k == 0
  
  if good:
    print(convert(s))
    continue
  
  answer = [ord('z') + 1]
  curAnswer = convert(answer)
 
  
  for indexes in arr:
    l = 0
    r = len(indexes) - 1
    m = 0
    good = False
    while l <= r:
      m = (l + r) >> 1
      
      
      currentIndex = indexes[m]
      
      cnt = [0 for _ in range(26)]
 
      for i in range(currentIndex):
        cnt[s[i]] += 1
      
      remLength = n - currentIndex
      
      leftCurrentLetter = s[currentIndex]
      rightCurrentLetter = 25
      currentLetter = 0
      while leftCurrentLetter <= rightCurrentLetter:
        currentLetter = (leftCurrentLetter + rightCurrentLetter) >> 1
        rem = [0 for _ in range(26)]
        for i in range(26):
          rem[i] = (k - (cnt[i] % k)) % k
        
        if rem[currentLetter] == 0:
          rem[currentLetter] += k
        
        if sum(rem) > remLength:    
          leftCurrentLetter = currentLetter + 1
          continue
        
        while sum(rem) < remLength:
          rem[0] += k
        
        currentAnswer = [s[i] for i in range(n)]
        currentAnswer[currentIndex] = currentLetter
        rem[currentLetter] -= 1
        itr = 0
        for i in range(currentIndex + 1, n):
          while rem[itr] == 0:
            itr += 1
          currentAnswer[i] = itr
          rem[itr] -= 1
        curString = convert(list(currentAnswer))
        if curAnswer > curString > convertedS:
          curAnswer = curString
          good = True
          rightCurrentLetter = currentLetter - 1
        else:
          leftCurrentLetter = currentLetter + 1
          
      if good:
        l = m + 1
      else:
        r = m - 1
  if curAnswer[0] == chr(ord('z') + 1) == 0:
    print(-1)
  else:
    print(curAnswer)
    
      
