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 > 0:
        print(-1)
        continue
    m = n/k
    letters = []
    supply = {}
    supply2 = {}
    for c in s:
        if not c in supply:
            if len(letters) == m:
                greater = False
                for l in letters:
                    if l > c:
                        greater = True
                        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 supply2[c] > 0:
            supply2[c] -= 1
        else:
            supply[c] += k
            supply2[c] += k
            letters.append(c)
    result = []
    equal = True
    for c in s:
        if c in supply and supply[c] > 0:
            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]:
            for j in range(supply[c]):
                result.append(c)
            supply[c] = 0
    print("".join(result))
