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 sys
import math
input = sys.stdin.readline
t = int(input())
pis = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for test in range(t):
	#n = int(input())
	[n, k] = list(map(int, input().split(" ")))	
	#a = list(map(int, input().split(" ")))
	s = input()
	res = [s[i] for i in range(n)]
	if n%k>0:
		print(-1)
	elif k==1:
		print(' '.join(res))
	else:
		z=[]
		p=[]
		m=n//k
		c=0
		i=0
		while c<m and (i<n):
			if s[i] in z:
				p[z.index(s[i])]+=1
				if p[z.index(s[i])]%k==1:
					c+=1
			else:
				z.append(s[i])
				p.append(1)
				c+=1
			i+=1
		ip=i-1
		zs = sorted(enumerate(z), key=lambda x:x[1])
		ps = [p[q[0]] for q in zs ]
		#print(ps)
		next = ''
		konec = False
		tempres = []
		ide = True
		while not konec and ide:
			ide = False
			for j in range(len(zs)):
				if zs[j][1]>s[i] and (ps[j]%k!=0):
					ps[j]+=1
					tempres.append(zs[j][1])
					konec = True
					ide = True
					i+=1
					break
				elif zs[j][1]==s[i] and (ps[j]%k!=0):
					ps[j]+=1
					tempres.append(zs[j][1])
					i+=1
					ide = True
					#print(tempres)
					break
		#print(tempres)
		#print(ps)
		if konec:
			#print(ip)
			#print(i)
			#print(tempres)
			for x in range(i-1-ip):
				res[ip+1+x]=tempres[x]
			#print(ps)
			for j in range(len(zs)):
				if ps[j]%k!=0:
					h = k - ps[j]%k
					for x in range(h):
						ps[j]+=1
						res[i]=zs[j][1]
						i+=1
				#print(res)
			#print(res)
		else:
			#print(tempres)
			for x in reversed(range(len(tempres))):
				for y in range(len(zs)):
					if zs[y][1]== tempres[x]:
						ps[y]-=1
				for j in range(len(zs)):
					if zs[j][1]>s[i-len(zs)+x] and (ps[j]%k!=0):
						ps[j]+=1
						tempres[x]=zs[j][1]
						konec = True
						ide = True
						break
				if konec:
					xpos = x
					break
			#print(tempres[:xpos+1])
			if konec:
				#print(ip)
				#print(xpos)
				for x in range(xpos+1):
					res[ip+1+x]=tempres[x]
				#print(ps)
				i=ip+xpos+2
				#print(i)
				#print(ps)
				for j in range(len(zs)):
					if ps[j]%k!=0:
						h = k - ps[j]%k
						for x in range(h):
							ps[j]+=1
							res[i]=zs[j][1]
							i+=1
				#print(res)
			else:
				#print(z)
				#print(p)
				if p[-1]==1:
					z.pop()
					p.pop()
				else:
					p[z.index(s[ip])]-=1
				#print(z)
				#print(p)
				if pis.index(s[ip])==25:
					print(-1)
				else:
					z.append(pis[pis.index(s[ip])+1])
					p.append(1)
					res[ip] = pis[pis.index(s[ip])+1]
					zs = sorted(enumerate(z), key=lambda x:x[1])
					ps = [p[q[0]] for q in zs ]
					konec = True
				i=ip+1		
				if konec:
					for j in range(len(zs)):
						if ps[j]%k!=0:
							h = k - ps[j]%k
							for x in range(h):
								ps[j]+=1
								res[i]=zs[j][1]
								i+=1
					if i<n:
						for x in range(k):
							res[-1-x]='a'
						
		print(' '.join(res))