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

gans = []
for _ in range(int(input())):
    n, k = map(int, input().split())
    u = list(input())
    for i in range(n):
        u[i] = ord(u[i]) - ord('a')
    z = []
    for i in range(26):
        z.append([])
        z[-1].append(0)
    z[u[0]][0] += 1
    z[u[0]][0] %= k
    for i in range(1, n):
        for j in range(26):
            z[j].append(z[j][i - 1])
        z[u[i]][i] += 1
        z[u[i]][i] %= k
    for i in range(n - 1, -1, -1):
        sm = 0
        for j in range(26):
            sm += (k - z[j][i]) % k
        if sm % k == (n - i - 1) % k and sm <= n - i - 1:
            if i == n - 1:
                ans = []
                for r in range(n):
                    ans.append(chr(u[r] + ord('a')))
                gans.append(''.join(ans))
                break
            ans = u[:i + 1]
            for j in range(u[i + 1] + 1, 26):
                if z[j][i] != 0:
                    ans.append(j)
                    z[j][i] += 1
                    z[j][i] %= k
                    break
            else:
                if sm + k > n - i - 1:
                    continue
                else:
                    ans.append(u[i + 1] + 1)
                    z[u[i + 1] + 1][i] = 1
            s = []
            for j in range(26):
                for r in range((k - z[j][i]) % k):
                    s.append(j)
            for j in range(n - len(ans) - len(s)):
                ans.append(0)
            ans += s
            for j in range(len(ans)):
                ans[j] = chr(ans[j] + ord('a'))
            gans.append(''.join(ans))
            break
    else:
        gans.append(str(-1))
print('\n'.join(gans))
            
