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
input = sys.stdin.readline
t = int(input())
for _ in range(t):
    n, k = map(int, input().split())
    s = input()[:-1]
    if n % k != 0:
        print(-1)
        continue
    t = [0] * 26
    for i in range(n):
        t[ord(s[i]) - ord('a')] += 1
    for i in range(26):
        if t[i] % k != 0:
            break
    else:
        print(s)
        continue
    for i in range(n - 1, -1, -1):
        t[ord(s[i]) - ord('a')] -= 1
        if s[i] == 'z':
            continue
        p = 0
        for j in range(26):
            p += -t[j] % k
        q = 0
        c = 1000
        for j in range(ord(s[i]) - ord('a') + 1, 26):
            q += -t[j] % k
            if(-t[j] % k > 0):
                c = min(c, j + ord('a'))
        if c == 1000:
            c = ord(s[i]) + 1
        c = chr(c)
        if q == 0:
            p += k - 1
        else:
            p -= 1
        if p <= n - i - 1 and p % k == (n - i - 1) % k:
            res = s[:i] + c
            t[ord(c) - ord('a')] += 1
            for j in range(26):
                res += chr(j + ord('a')) * (-t[j] % k)
            while len(res) < n:
                res += 'a' * k
            print(res)
            break