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

for i in range(int(input())):
    n, k = map(int, input().split())
    s = input()
    if n % k:
        print(-1)
        continue
    m = n//k
    letters = []
    supply = {}
    supply2 = {}
    diff = 0
    for j in range(len(s)):
        c = s[j]
        if not (c in supply2 and supply2[c]):
            if len(letters) == m:
                greater = False
                available = []
                for c2 in supply2:
                    if supply2[c2] > 0:
                        available.append(c2)
                available.sort()
                greatest = available[-1]
                for x in range(j, 0, -1):
                    if greatest > s[x]:
                        greater = True
                        diff = x
                        break
                if not greater:
                    last = letters[-1]
                    new_last = chr(ord(last)+1)
                    if not new_last in supply:
                        supply[new_last] = k
                    else:
                        supply[new_last] += k
                    supply[last] -= k
                    letters[-1] = new_last
                break
            supply[c] = k
            supply2[c] = k
            letters.append(c)
        if not supply2[c]:
            supply[c] += k
            supply2[c] += k
            letters.append(c)
        supply2[c] -= 1
    result = []
    if diff:
        for j in range(diff):
            result.append(s[j])
            supply[s[j]] -= 1
        available = []
        for c2 in supply:
            if supply[c2] > 0:
                available.append(c2)
            available.sort()
        for c2 in available:
            if c2 > s[diff]:
                result.append(c2)
                supply[c2] -= 1
    else:
        equal = True
        for c in s:
            if c in supply and supply[c]:
                result.append(c)
                supply[c] -= 1
            else:
                available = []
                for c2 in supply:
                    if supply[c2] > 0:
                        available.append(c2)
                available.sort()
                for c2 in available:
                    if c2 > c:
                        result.append(c2)
                        supply[c2] -= 1
                        equal = False
                        break
                if not equal:
                    break
    letters.sort()
    for c in letters:
        if supply[c] > 0:
            for j in range(supply[c]):
                result.append(c)
            supply[c] = 0
    print("".join(result))
