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, m = vars()
	s = list(input())

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

	ans = []
	cnt = Counter(s)
	need = 0

	for c in cnt:
		need += ((cnt[c] + m - 1) // m) * m - cnt[c]
 
	if not need:
		print(''.join(s))
		return


	for i in range(n - 1, -1, -1):
		need -= ((cnt[s[i]] + m - 1) // m) * m - cnt[s[i]]
		cnt[s[i]] -= 1
		need += ((cnt[s[i]] + m - 1) // m) * m - cnt[s[i]]

		for j in range(ord(s[i]) + 1, 123):

			prev_need = need 
			char = chr(j)

			need -= ((cnt[char] + m - 1) // m) * m - cnt[char]
			cnt[char] += 1
			need += ((cnt[char] + m - 1) // m) * m - cnt[char]

			if i + need + 1 <= n:
				ans = ['' for k in range(n)]
				suf = []
				for k in range(i):
					ans[k] = s[k]

				ans[i] = char

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

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

				suf.sort()

				top = i + 1
				for k in range(len(suf)):
					ans[top] = suf[k]
					top += 1

				print(''.join(ans))
				return

			need = prev_need
			cnt[char] -= 1




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()