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
    diff2 = 0
    for j in range(len(s)):
        c = s[j]
        if not (c in supply2 and supply2[c]) and len(letters) == m:
            available = []
            for c2 in supply2:
                if supply2[c2] > 0:
                    available.append(c2)
            available.sort()
            greatest = available[-1]
            for x in range(j, diff2, -1):
                if greatest > s[x]:
                    diff = x
                    break
            break
        if c not in supply2:
            supply[c] = k
            supply2[c] = k
            letters.append(c)
            diff2 = j
        elif not supply2[c]:
            supply[c] += k
            supply2[c] += k
            letters.append(c)
            diff2 = j
        supply2[c] -= 1
    result = []
    equal = True
    for c in letters:
        if supply2[c]:
            equal = False
            break
    if equal:
        print(s)
    else:
        if diff > diff2:
            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:
            for j in range(diff2):
                result.append(s[j])
                supply[s[j]] -= 1
            c = s[diff2]
            c1 = chr(ord(c)+1)
            letters[-1] = c1
            supply[c] -= k
            if c1 in supply:
                supply[c1] += k
            else:
                supply[c1] = k
            result.append(c1)
            supply[c1] -= 1
        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))
