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
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush,heappop,heapify
from itertools import permutations,combinations
from itertools import accumulate as ac
mod = int(1e9)+7
#mod = 998244353
 
ip = lambda : int(stdin.readline())
inp = lambda: map(int,stdin.readline().split())
ips = lambda: stdin.readline().rstrip()
out = lambda x : stdout.write(str(x)+"\n")

alp = 'abcdefghijklmnopqrstuvwxyz'
ele = {}
mark = {}
for i in range(len(alp)):
    ele[alp[i]] = i
    mark[i] = alp[i]
  
t = ip()
for _ in range(t):
    n,k = inp()
    s = ips()
    d = Counter(s)
    f = True
    for i in d:
        if d[i]%k == 0:
            pass
        else:
            f = False
            break
    if f:
        ans = s
    else:
        if len(s)%k == 0:
            s = list(s)
            ch = Counter()
            pref = [None]*n
            for i in range(n):
                ch[s[i]] += 1
                pref[i] = Counter(ch)
            place = -1
            for i in range(n-1,-1,-1):
                place += 1
                store = place
                flag2 = False
                for j in alp:
                    if j>s[i]:
                        temp = j
                        cur = Counter(pref[i])
                        cur[s[i]] -= 1
                        cur[j] += 1
                        flag = True
                        for jj in cur:
                            cur[jj] %= k
                            if cur[jj] == 0:
                                pass
                            else:
                                left = k-cur[jj]
                                if place>= left:
                                    place -= left
                                else:
                                    flag = False
                                    break
                        if flag:
                            if place%k == 0:
                                elem = j
                                pos = i
                                leftover = place
                                flag2 = True
                                break
                if flag2:
                    break
                place = store

            s = list(s)
            s[pos] = elem
            count = 0
            for i in range(pos+1,n):
                count += 1
            dic = Counter()
            for i in range(pos+1):
                dic[s[i]] += 1
            pt = pos+1
            for i in range(leftover):
                s[pt] = 'a'
                pt += 1
            count -= left
            ch = sorted(list(dic.keys()))
            for i in ch:
                if dic[i]%k == 0:
                    pass
                else:
                    dic[i] %= k
                    left = k-dic[i]
                    for j in range(left):
                        s[pt] = i
                        pt += 1
                    count -= left
            ans = ''.join(s)
                
            
                        
        else:
            ans = -1
    print(ans)
    
    
    
            
    
    
    
        
    
        
        
               
