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

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """4
# 4 2
# abcd
# 3 1
# abc
# 4 3
# aaaa
# 9 3
# abaabaaaa
# """
# sys.stdin = io.StringIO(_INPUT)


def solve(N, K, S):

    if N % K != 0:
        return '-1'

    S = list(S)

    # 先頭を 'a' 埋め
    n = len(S) % K
    if n > 0:
        S = ['a'] * (K - n) + S

    # 変更量，変更先の文字を決める
    counter = collections.Counter(S)
    if not any((1 for n in counter.values() if n % K > 0)):
        return ''.join(S)
    d = {}
    for c, n in counter.items():
        d[c] = n

    for i in reversed(range(N)):
        # S[:i] はそのまま。i文字目以降を変更する

        si_before = S[i]
        d[S[i]] -= 1

        for t in range(ord(S[i]) + 1, ord('z') + 1):

            c = chr(t)

            # S[i] を c に変更
            S[i] = c
            if c in d:
                d[c] += 1
            else:
                d[c] = 1


            l = 0
            for n in d.values():
                if n % K > 0:
                    l += (K - (n % K))
            if l <= N - (i+1):
                L = []
                for c1 in sorted(d.keys()):
                    if d[c1] % K > 0:
                        L.append(c1 * (K - (d[c1] % K)))
                return ''.join(S[:i+1]) + 'a' * (N - (i+1) - l) + ''.join(L)

            # 元に戻す
            d[c] -= 1

        S[i] = si_before

    return '-1'



def main():
    T0 = int(input())
    for _ in range(T0):
        N, K = map(int, input().split())
        S = input()
        ans = solve(N, K, S)
        print(ans)

if __name__ == '__main__':
    main()
