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

sys.setrecursionlimit(10**5)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
inf = 10**16
md = 10**9+7
# md = 998244353

for _ in range(II()):
    n, k = MI()
    word = SI()
    if n%k:
        print(-1)
        continue

    aa = [ord(a)-97 for a in word]

    cnt = [0]*26
    for a in aa: cnt[a] += 1

    if sum((k-cnt[a]%k)%k for a in range(26)) == 0:
        print(word)
        continue

    def solve(i):
        if sum((k-cnt[a]%k)%k for a in range(26)) > n-i: return ""
        for sa in range(aa[i]+1, 26):
            issa = False
            if cnt[sa]%k: issa = True
            if issa: cnt[sa] += 1
            else: cnt[sa] += k-1
            use = []
            for a in range(26):
                use += [a]*((k-cnt[a]%k)%k)
            rem = n-i-1-len(use)
            if rem < 0:
                if issa: cnt[sa] -= 1
                else: cnt[sa] -= k-1
                continue
            use += [0]*rem
            use.sort()
            return "".join(chr(a+97) for a in aa[:i]+[sa]+use)
        return ""

    for i in range(n-1, -1, -1):
        cnt[aa[i]] -= 1
        ans = solve(i)
        if ans:
            print(ans)
            break
