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


def good(s, k):
    return all(c % k == 0 for c in Counter(s).values())


def construct(n, k, s, i, ch):
    cnt = Counter()
    r = n
    res = []
    for j in range(i):
        res.append(s[j])
        cnt[s[j]] += 1
        if cnt[s[j]] % k == 1:
            r -= k
    res.append(ch)
    cnt[ch] += 1
    if cnt[ch] % k == 1:
        r -= k
    while r > 0:
        res.append('a')
        r -= 1
    for j in range(ord('a'), ord('z') + 1):
        for _ in range((k - cnt[chr(j)] % k) % k):
            res.append(chr(j))
    return ''.join(res)


def solve(n, k, s):
    if n % k != 0:
        return None
    if good(s, k):
        return s
    cnt = Counter()
    r = n
    best = None
    for i in range(n):
        for j in range(ord(s[i]) + 1, ord('z') + 1):
            ch = chr(j)
            if cnt[ch] % k != 0 or r > 0:
                best = (i, ch)
                break
        cnt[s[i]] += 1
        if cnt[s[i]] % k == 1:
            if r == 0:
                break
            r -= k
    return construct(n, k, s, best[0], best[1])


t = int(input())
for _ in range(t):
    n, k = map(int, input().split())
    s = input()
    res = solve(n, k, s)
    if res:
        print(res)
    else:
        print(-1)
