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

from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math


def inp(force_list=False):
    re = map(int, raw_input().split())
    if len(re) == 1 and not force_list:
        return re[0]
    return re

def inst():
    return raw_input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

mod = 1000000007

def my_main():
    kase = inp()
    pans = []
    for i in range(kase):
        n, k = inp()
        ost = inst()
        st = [ord(c)-ord('a') for c in ost]
        ps = [[0] for i in range(26)]
        for i in st:
            for j in range(26):
                if i==j:
                    ps[j].append(ps[j][-1]+1)
                else:
                    ps[j].append(ps[j][-1])
        di = 1
        for i in range(26):
            if ps[i][-1]%k:
                di = 0
        if n%k!=0:
            pans.append('-1')
            continue
        if di:
            pans.append(ost)
            continue
        l, r = 0, n
        ans = []
        def check(mid):
            if st[mid] == 25:
                return 0
            use = n-mid
            tp = []
            for j in range(26):
                tp.append(ps[j][mid])
            ok = 0
            for j in range(26):
                if tp[j] % k==0:
                    continue
                else:
                    if j > st[mid]:
                        ok = 1
                    use -= k - tp[j] % k
            if ok==0 and use==0:
                return 0
            if use>0 and use%k==0:
                return 1
            return use == 0
        while l < r - 1:
            mid = (l+r)/2
            if check(mid):
                l, r = mid, r
            else:
                l, r = l, mid
        if not check(l):
            pans.append('-1')
            continue
        ans = [st[j] for j in range(l)]
        so = []
        mid = l
        use = n-mid
        tp = []
        ckck = -1
        for j in range(26):
            tp.append(ps[j][mid])
        ok = 0
        for j in range(26):
            if tp[j] % k==0:
                continue
            else:
                for i in range(k - tp[j] % k):
                    so.append(j)
                if j > st[mid] and ok==0:
                    ok = 1
                    ckck = j
                use -= k - tp[j] % k
        if use:
            if ckck == -1 or ckck > st[mid] + 1:
                ckck = st[mid] + 1
                use -= k
                for i in range(k):
                    so.append(ckck)
                for i in range(use):
                    so.append(0)
            else:
                for i in range(use):
                    so.append(0)
        so.sort()
        ans.append(ckck)
        for i in range(n-mid):
            if ckck!= -1 and so[i]==ckck:
                ckck = -1
                continue
            ans.append(so[i])
        ans = ''.join(map(lambda i: chr(97+i), ans))
        pans.append(ans)
    print '\n'.join(pans)
# print int('101010', 2), int('11011', 2)
my_main()
