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

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
#define int long long 
#define ll int
#define all(a) a.begin(),a.end()	
#define rev(a) a.rbegin(),a.rend()	
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; //less_equal for multiset
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
const double pi=acosl(-1);



void solve()
{
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	vector<int> c(26);
	for(auto x:s) c[x-'a']++;
	int tot=0;
	fj(0,26)
	{
		tot+=(k-c[j]%k)%k;
	}
	if(tot==0)
	{
		cout<<s<<'\n';
		return ;
	}
	// cout<<tot<<'\n';
	for(int i=n-1;i>=0;i--)
	{
		tot=0;
		fj(0,26)
		{
			tot+=(k-c[j]%k)%k;
		}

		fj((s[i]-'a')+1,26)
		{
			tot-=(k-c[j]%k)%k;
			c[j]++;
			tot+=(k-c[j]%k)%k;
			tot-=(k-c[s[i]-'a']%k)%k;
			c[s[i]-'a']--;
			tot+=(k-c[s[i]-'a']%k)%k;
			// cout<<tot<<'\n';
			if(tot<=n-i-1&&(n-i-1-tot)%k==0)
			{
				string out="";
				for(int x=0;x<i;x++) out+=s[x];
				out+=char('a'+j);
				int left=n-i-1-tot;
				// cout<<left<<'\n';
				for(int x=0;x<26;x++)
				{
					c[x]=(k-c[x]%k)%k;
					if(!x)
						c[x]+=left;
				}
				for(int x=0;x<26;x++)
				{
					for(int y=0;y<c[x];y++)
					{
						out+=char(x+'a');
					}
				}
				cout<<out<<'\n';

				return ;
			}

			tot-=(k-c[j]%k)%k;
			c[j]--;
			tot+=(k-c[j]%k)%k;;
			tot-=(k-c[s[i]-'a']%k)%k;
			c[s[i]-'a']++;
			tot+=(k-c[s[i]-'a']%k)%k;
		}

		c[s[i]-'a']--;
	}
	cout<<-1<<'\n';

	
	
}

signed main()
{
	FAST;
	int tt=1;
	cin>>tt;	
	while(tt--)
	{
		solve();
	}	
}










//int dx[] = {+1,-1,+0,+0,-1,-1,+1,+1}; // Eight Directions
//int dy[] = {+0,+0,+1,-1,+1,-1,-1,+1}; // Eight Directions
//int dx[]= {-2,-2,-1,1,-1,1,2,2}; // Knight moves
//int dy[]= {1,-1,-2,-2,2,2,-1,1}; // Knight moves
// For (a^b)%mod, where b is large, replace b by b%(mod-1).
// a+b = (a|b)+(a&b)
// a+b = 2*(a&b)+(a^b)
