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

def main():
    import sys
    input = sys.stdin.readline
    T = int(input())
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    da = dict()
    ANS = []
    for i, x in enumerate(alpha):
        da[x] = i
    for _ in range(T):
        n, k = map(int, input().split())
        s = input().rstrip()
        if n % k != 0:
            ANS.append('-1')
            continue
        d = dict()
        for x in s:
            if x not in d:
                d[x] = 0
            d[x] += 1

        flag = True
        for x in d:
            if d[x] % k > 0:
                flag = False
        if flag:
            ANS.append(s)
            continue

        s = s[::-1]
        for i in range(n):
            r = 0
            d[s[i]] -= 1
            ret = []
            for x in d:
                if d[x] % k > 0:
                    r += k-(d[x] % k)
            if s[i] == 'z':
                continue
            if i+1 == r:
                for j in range(da[s[i]]+1, 26):
                    x = alpha[j]
                    if x in d and d[x] % k != 0:
                        ret.append(x)
                        d[x] += 1
                        for y in alpha:
                            if y in d and d[y] % k != 0:
                                for j2 in range(k - d[y] % k):
                                    ret.append(y)
                        # print(s[::-1], x)
                        ANS.append(''.join([s[i+1:][::-1], ''.join(ret)]))
                        flag = True
                        break
                if flag:
                    break
            elif i+1 > r:
                id = da[s[i]]
                if alpha[id+1] not in d:
                    d[alpha[id+1]] = 0
                d[alpha[id+1]] += 1
                r2 = i
                # print(d)
                for y in alpha:
                    if y in d and d[y] % k != 0:
                        for j2 in range(k - (d[y] % k)):
                            ret.append(y)
                            r2 -= 1
                ret2 = []
                for j in range(r2):
                    ret2.append('a')
                ANS.append(''.join([s[i+1:][::-1], alpha[id+1], ''.join(ret2) ,''.join(ret)]))
                flag = True
                break

        if flag == False:
            ANS.append('-1')
    print(*ANS, sep='\n')


main()
