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 math, sys
from collections import defaultdict, Counter, deque
from bisect import bisect_left, bisect_right

INF = float('inf')
MOD = int(1e9) + 7
MAX = int(1e6) + 1


def check(cnt, k):
	for c in cnt:
		if cnt[c] % k != 0:
			return False

	return True


def solve():
	n, k = vars()
	s = list(input())

	if n % k != 0:
		print(-1)
		return

	l, r = 0, n - 1
	ans = ['z' for i in range(n)]
	while l <= r:
		tmp = ['' for i in range(n)]
		res = 1

		m = (l + r) // 2

		for i in range(ord(s[m]), 123):
			char = chr(i)
			cnt = defaultdict(int)

			for j in range(m):
				tmp[j] = s[j]
				cnt[tmp[j]] += 1

			tmp[m] = char
			cnt[char] += 1
			res = 1

			suf = []

			for c in cnt:
				add = ((cnt[c] + k - 1) // k) * k - cnt[c]
				suf += [c] * add

			while len(suf) + m + 1 < n:
				suf.append('a')

			suf.sort()
			top = m + 1

			for j in range(len(suf)):
				if top >= n:
					break
				tmp[top] = suf[j]
				cnt[suf[j]] += 1
				top += 1

			if not check(cnt, k) or tmp < s:
				res = 0

			if res:
				break

		if res:
			ans = list(tmp)
			l = m + 1
		else:
			r = m - 1

	print(''.join(ans))



def main():
	t = 1 
	t = int(input())
	for _ in range(t):
		solve()
















def gcd(a, b):
	while b:
		a, b = b, a%b
	return a

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False 

	sys.stdout.write(end)

primes = [ 1 for i in range(MAX) ]
def sieve():
	global primes
	primes[0] = primes[1] = 0 
	i = 2
	while i <= MAX ** 0.5:
		j = i * i
		while primes[i] and j < MAX:
			if j % i == 0:
				primes[j] = 0 
			j += i 
		i += 1

def vars():
	return map(int, input().split())
 
def array():
	return list(vars())

if __name__ == "__main__":
	main()