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 collections

t = int(input())

for _ in range(t):
    n, k = map(int, input().split())
    s = input()
    if n % k != 0:
        print(-1)
        continue

    s = [ord(x) - ord('a') for x in s]

    dd = n // k

    sets = []
    totalChars = collections.defaultdict(lambda: 0)

    h = None
    for i, c in enumerate(s):
        if totalChars[c] == 0:
            if len(sets) == dd:
                h = i
                break
            sets.append([c, i])
            totalChars[c] += k - 1
        else:
            totalChars[c] -= 1

    if h:
        for j in range(26):
            if totalChars[j] == 0:
                continue
            if j > s[h]:
                h = None
                break

    if h:
        for i in reversed(range(h)):
            for j in range(s[i] + 1, 26):
                if totalChars[j] == 0:
                    continue
                h = None
                s[i] = j
                break
            if h is None:
                break

    if h:
        d = len(sets) - 1
        while d >= 0:
            sets[d][0] += 1
            if sets[d][0] == 26:
                sets[d][0] = 0
                d -= 1
            else:
                break

    # print(sets)

    lastSets = {}
    for sa, si in sets:
        lastSets[si] = sa
    totalChars = collections.defaultdict(lambda: 0)
    res = ""
    anyThing = False
    for i, c in enumerate(s):
        ch = None
        if i in lastSets:
            totalChars[lastSets[i]] += k

        for j in range(0 if anyThing else c, 26):
            if totalChars[j] != 0:
                ch = j
                totalChars[j] -= 1
                break
        if ch is None:
            anyThing = True
            for j in range(26):
                if totalChars[j] != 0:
                    ch = j
                    totalChars[j] -= 1
                    break
        if not anyThing and ch > c:
            anyThing = True

        res += chr(ch + ord('a'))

    print(res)