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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define sz size()
#define ff first
#define ss second
#define mod 1000000007
#define pie 3.14159265359
#define minheap priority_queue<int , vector<int> , greater<int> > 
#define maxheap priority_queue<int> 	
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
ll get(ll num,ll k)
{
	return (k-(num%k))%k;
}
int main()			
{
	fast;
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,i,j,k;
		cin>>n>>k;
		string s;
		cin>>s;
		if(n%k)
		{
			cout<<"-1 \n";
			continue;
		}
		ll alpha[26]={0};
		for(i=0;i<n;i++)
		alpha[s[i]-'a']++;
		
		bool con=false;
		ll rem=0;
		for(i=0;i<26;i++)
		{
			rem+=get(alpha[i],k);
		}
		if(rem==0)
		{
			cout<<s<<"\n";
		   continue;
		}
		//cout<<"rem: "<<rem<<"\n";
		for(i=n-1;i>=0;i--)
		{
			rem=rem-get(alpha[s[i]-'a'],k);
			alpha[s[i]-'a']--;
			rem+=get(alpha[s[i]-'a'],k);
			ll temp=rem;
			for(j=s[i]-'a'+1;j<26;j++)
			{
				char c='a'+j;
				rem=rem-get(alpha[j],k);
				alpha[j]++;
				rem+=get(alpha[j],k);
				if(rem+i+1<=n)
				{
					for(ll z=0;z<i;z++)
					cout<<s[z];
					cout<<c;
					string ans="";
					for(ll p=0;p<26;p++)
					{
						ll f=get(alpha[p],k);
						char c1='a'+p;
						while(f--)
						{
							ans+=c1;
						}
					}
					ll dif=-rem+(n-i-1);
					while(dif--)
					ans+='a';
					sort(ans.begin(),ans.end());
					cout<<ans<<"\n";
					con=true;
					break;
				}
				alpha[j]--;
				rem=temp;
			}
			if(con)
			break;
		}
	}
}