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 solve(n, k, s):
    if n % k:
        return -1
    if k == 1:
        return s
    d = {}; cnt = 0; pref = []
    for i in range(n):
        pref.append(cnt)
        if s[i] not in d:
            d[s[i]] = 1
        else:
            d[s[i]] += 1
        #cnt += k
        if d[s[i]] % k == 1:
            cnt += k - 1
        else:
            cnt -= 1
    good = True
    for ke in d:
        if d[ke] % k:
            good = False
            break
    if good:
        return s

    for i in range(n - 1, -1, -1):
        d[s[i]] -= 1
        len_suf = n - i - 1
        #print(pref[i], 1 + len_suf)
        if pref[i] > 1 + len_suf:
            continue
        if pref[i] == 1 + len_suf:
            for j in range(ord(s[i]) + 1, ord("z") + 1):
                if chr(j) in d and d[chr(j)] % k:
                    s2 = s[:i]
                    s2 += chr(j)
                    d[chr(j)] += 1
                    keys = sorted(d.keys())
                    for ke in keys:
                        if d[ke] % k:
                            s2 += ke * (k - d[ke] % k)
                    return s2
            continue
        else:   # pref[i] < 1 + len_suf
            if s[i] == "z":
                continue
            s2 = s[:i]
            s2 += chr(ord(s[i]) + 1)
            last = s2[-1]
            if last not in d:
                d[last] = 1
            else:
                d[last] += 1
            end_s = ""
            keys = sorted(d.keys())
            for ke in keys:
                if d[ke] % k:
                    end_s += ke * (k - d[ke] % k)
            remaining = n - len(s2) - len(end_s)
            #print(remaining, "dk")
            return s2 + "a" * remaining + end_s

def main():
    T = int(input())
    for _ in range(T):
        n, k = map(int, input().split())
        s = input()
        print(solve(n, k, s))
main()