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
input = lambda: sys.stdin.readline().rstrip("\r\n")
inp = lambda: list(map(int,sys.stdin.readline().rstrip("\r\n").split()))
mod = 10**9+7; Mod = 998244353; INF = float('inf')
#______________________________________________________________________________________________________
# from math import *
# from bisect import *
# from heapq import *
# from collections import defaultdict as dd
# from collections import OrderedDict as odict
# from collections import Counter as cc
# from collections import deque
# sys.setrecursionlimit(5*10**5+100) #this is must for dfs
# ______________________________________________________________________________________________________
# segment tree for range minimum query
# n = int(input())	
# a = list(map(int,input().split()))
# st = [float('inf') for i in range(4*len(a))]
# def build(a,ind,start,end):
# 	if start == end:
# 		st[ind] = a[start]
# 	else:
# 		mid = (start+end)//2
# 		build(a,2*ind+1,start,mid)
# 		build(a,2*ind+2,mid+1,end)
# 		st[ind] = min(st[2*ind+1],st[2*ind+2])
# build(a,0,0,n-1)
# def query(ind,l,r,start,end):
# 	if start>r or end<l:
# 		return float('inf')
# 	if l<=start<=end<=r:
# 		return st[ind]
# 	mid = (start+end)//2
# 	return min(query(2*ind+1,l,r,start,mid),query(2*ind+2,l,r,mid+1,end))
# ______________________________________________________________________________________________________
# Checking prime in O(root(N))
# def isprime(n):
#     if (n % 2 == 0 and n > 2) or n == 1: return 0
#     else:
#         s = int(n**(0.5)) + 1
#         for i in range(3, s, 2):
#             if n % i == 0:
#                 return 0
#         return 1
# def lcm(a,b):
#   return (a*b)//gcd(a,b)
# ______________________________________________________________________________________________________
# nCr under mod
# def C(n,r,mod = 10**9+7):
#   if r>n:
#       return 0
#   num = den = 1
#   for i in range(r):
#       num = (num*(n-i))%mod
#       den = (den*(i+1))%mod
#   return (num*pow(den,mod-2,mod))%mod
# ______________________________________________________________________________________________________
# For smallest prime factor of a number
# M = 2*(10**5)+10
# pfc = [i for i in range(M)]
# def pfcs(M):
#   for i in range(2,M):
#       if pfc[i]==i:
#           for j in range(i+i,M,i):
#               if pfc[j]==j:
#                   pfc[j] = i
#   return
# pfcs(M)
# ______________________________________________________________________________________________________
tc = 1
tc, = inp()
for _ in range(tc):
	n,k = inp()
	s = str(input())
	if n%k!=0:
		print(-1)
		continue
	low,high = 0,n
	def check(s,k,n,lol):
		counter = [0]*26
		for i in s:
			char = ord(i)-ord('a')
			counter[char]+=1
			counter[char]%=k
		extra = []
		i = len(s)
		j = 25
		while(i<n and j>=0):
			while(i<n and counter[j]%k!=0):
				extra.append(chr(ord('a')+j))
				counter[j]+=1
				i+=1
			j-=1
		for ind in range(26):
			if counter[ind]>0:
				break
		if (i<n):
			extra.extend([chr(ord('a')+ind)]*(n-i))
			counter[0]+=n-i
		# print("INSIDE",counter,s)
		for i in counter:
			if i%k!=0:
				return ""
		if lol==0:
			return s+''.join(extra)
		return s+''.join(extra[::-1])
	def valid(s,mid,k):
		if mid==len(s):
			return check(s,k,n,1)

		for i in range(ord(s[mid])+1,ord('z')+1):
			res = check(s[:mid]+chr(i),k,n,1)
			if res>=s:
				return res
		res = check(s[:mid+1],k,n,0)
		if res>=s:
			return res
		return ""
	ans = ""
	while(low<=high):
		mid = (low+high)//2
		res = valid(s,mid,k)
		# print(mid,res,"RES")
		if len(res)>0:
			ans = res
			low = mid+1
		else:
			high = mid-1
	if len(ans)>0:
		print(ans)
	else:
		print(-1)
	# print()