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

import io
import os

from collections import Counter, defaultdict, deque


def solve(N, K, S):
    if N % K != 0:
        return -1
    ordA = ord("a")
    A = [ord(x) - ordA for x in S]

    freq = [0] * 26

    for x in A:
        freq[x] += 1

    if all(v % K == 0 for k, v in enumerate(freq)):
        return S

    minNeed = sum((K - v) % K for v in freq)
    for i in reversed(range(N)):
        x = A[i]
        freq[x] -= 1
        minNeed += 1
        if (freq[x] % K) == 0:
            minNeed -= K

        for y in range(x + 1, 26):
            if (freq[y] % K) == 0:
                minNeed += K
            freq[y] += 1
            minNeed -= 1
            if DEBUG:
                need = {
                    k: (K - count) % K
                    for k, count in enumerate(freq)
                    if (K - count) % K != 0
                }

                assert minNeed == sum(need.values())
            have = N - 1 - i
            if have >= minNeed and (have - minNeed) % K == 0:
                ch = chr(ord("a") + y)

                if False and DEBUG:
                    print(
                        "consider",
                        S[:i],
                        "changed",
                        ch,
                        "need",
                        {chr(ord("a") + k): count for k, count in need.items()},
                        "have",
                        have,
                    )

                need = {
                    k: (K - count) % K
                    for k, count in enumerate(freq)
                    if (K - count) % K != 0
                }
                ans = [S[:i], ch]
                pad = have - minNeed
                if 0 in need:
                    need[0] += pad
                else:
                    need[0] = pad
                for k in sorted(need.keys()):
                    ans.append(chr(ord("a") + k) * need[k])

                ret = "".join(ans)
                assert len(ret) == N
                return ret

            freq[y] -= 1
            minNeed += 1
            if (freq[y] % K) == 0:
                minNeed -= K

    return -1


def solve1(N, K, S):
    import itertools

    best = -1
    for A in itertools.product(*[range(26) for i in range(N)]):
        S2 = "".join(chr(ord("a") + x) for x in A)
        if S <= S2 and all(v % K == 0 for k, v in Counter(S2).items()):
            if best != -1:
                best = min(best, S2)
            else:
                best = S2
    return best


DEBUG = False
if DEBUG:
    import random

    random.seed(0)
    for _ in range(1):
        N = 10 ** 5
        K = 100
        S = "".join([chr(ord("a") + random.randint(0, 25)) for i in range(N)])

        print("TC", _, N, K)  # , S)
        ans = solve(N, K, S)
        print(ans)
    exit()

if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    TC = int(input())
    for tc in range(1, TC + 1):
        N, K = [int(x) for x in input().split()]
        S = input().decode().rstrip()
        ans = solve(N, K, S)
        print(ans)
