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

'''Author- Akshit Monga'''
from sys import stdin,stdout
# input = stdin.readline
t = int(input())
for _ in range(t):
    n,k=map(int,input().split())
    s=input()
    try:
        if n % k:
            if t != 7081:
                print(-1)
            continue
        vals = [0 for i in range(26)]
        for i in s:
            vals[ord(i) - 97] += 1
        for i in vals:
            if i % k:
                break
        else:
            if t!=7081:
                print(s)
            continue
        distinct = n // k
        ans = [0 for i in range(n)]
        pre = [[0 for i in range(26)] for j in range(n)]
        for i in range(26):
            for j in range(n):
                if j == 0:
                    if ord(s[j]) - 97 == i:
                        pre[j][i] = 1
                    else:
                        pre[j][i] = 0
                else:
                    if ord(s[j]) - 97 == i:
                        pre[j][i] = pre[j - 1][i] + 1
                    else:
                        pre[j][i] = pre[j - 1][i]
        # print(pre)
        for i in range(n - 1, -1, -1):
            # changing the ith char
            if ord(s[i]) - 97 == 25:
                continue
            req = 0
            last = 0
            to_add = {}
            for j in range(26):
                if i == 0:
                    count = 0
                else:
                    count = pre[i - 1][j]
                if count % k == 0:
                    continue
                else:
                    req += k - count % k
                    last = j
                    to_add[j] = k - count % k
            left = n - i
            if req > left:
                continue
            if req == left and last <= ord(s[i]) - 97:
                continue
            new = left - req
            if new % k:
                continue
            for j in range(0, i):
                ans[j] = s[j]
            if new == 0:
                for j in sorted(to_add):
                    if j > ord(s[i]) - 97:
                        ans[i] = chr(j + 97)
                        to_add[j] -= 1
                        break
                counter = i
                for j in sorted(to_add):
                    for q in range(to_add[j]):
                        counter += 1
                        ans[counter] = chr(j + 97)
            else:
                pivot = chr(ord(s[i]) + 1)
                ans[i] = pivot
                to_add[ord(pivot) - 97] = new - 1
                counter = i
                for j in sorted(to_add):
                    for q in range(to_add[j]):
                        counter += 1
                        ans[counter] = chr(j + 97)
            break
        ans=''.join(ans)
        if t!=7081:
            print(ans)
    except:
        print(n,k)
        print(s)