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

from collections import Counter

for _ in range(int(input())):
    n, k = map(int, input().split())
    s = input()
    if n % k:
        print(-1)
    elif k == 1:
        print(s)
    else:
        stat = Counter(s)
        if all(v % k == 0 for v in stat.values()):
            print(s)
            continue
        usage = [0] * 26
        last_i = -1
        last_new_ch = 'z'
        suppl = 0
        for i in range(n):
            idx = ord(s[i]) - ord('a')

            usage[idx] += 1
            old_suppl = suppl
            if usage[idx] % k == 1:
                suppl += k - 1
            else:
                suppl -= 1

            for j in range(26):
                if chr(ord('a') + j) > s[i]:
                    if usage[j] % k == k - 1:
                        last_new_ch = chr(ord('a') + j)
                        last_i = i
                        break
                    elif usage[j] % k == 0:
                        if old_suppl + k - 1 <= (n - i - 1):
                            last_new_ch = chr(ord('a') + j)
                            last_i = i
                            break
                    elif old_suppl - 1 <= (n - i - 1):
                        last_new_ch = chr(ord('a') + j)
                        last_i = i
                        break
            
        if last_i == -1:
            print(last_i)
            continue
        else:
            # print(last_i, usage)
            prefix = s[:last_i] + last_new_ch
            stat = Counter(prefix)
            ans = [prefix]
            for j in range(26):
                cur = stat.get(chr(ord('a') + j), 0) % k 
                if cur > 0:
                    ans.append(chr(ord('a') + j) * (k - cur))
            print(''.join(ans))
            continue
