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>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
typedef long long ll;
using namespace std;
#define V vector<ll>
#define VV vector<vector<ll>>
#define A(a) for(auto &x:a)cin>>x;
#define C(a) cout<<(#a);for(auto x:a)cout<<" "<<x;cout<<endl;
#define D(a) cout<<(#a)<<"-> "<<a<<endl;
#define DD(a,b) cout<<(#a)<<"-> "<<a<<" "<<(#b)<<"-> "<<b<<endl;
#define Q int tt,qq; cin>>tt ;for(qq=1;qq<=tt;qq++)
#define I ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define B(a) a.begin(),a.end()
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
ll M=1000000007,inf=92233720368547;
#define N 200010
int main()
{
	Q
	{
		ll n,k,i,j,l,x;
		cin>>n>>k;
		string s;
		cin>>s;
		if(n%k){cout<<-1<<endl;continue;}
		V a(26),b(26);
		for(i=0;i<n;i++){
			a[s[i]-'a']++;
		}
		ll t=0;
		for(auto x:a)if(x%k)t++;
		if(t==0){cout<<s<<endl;continue;}
		for(i=n-1;i>=0;i--){
			a[s[i]-'a']--;
			for(j=s[i]-'a'+1;j<26;j++){
				t=0;
				for(l=0;l<26;l++){
					x=a[l];
					if(l==j)x++;
					if(x%k)t+=k-x%k;
				}
			//	DD(j,t)
				if(t<=n-i-1){t=-1;break;}
			}
			if(t==-1)break;
		}
		// DD(i,j)
		for(l=0;l<i;l++){cout<<s[l];b[s[l]-'a']++;}
		char c='a'+j;
		cout<<c;
		b[j]++;
		// C(b)
		for(i=0;i<26;i++){
			n-=b[i];
			if(b[i]%k){
				b[i]=k-b[i]%k;
				n-=b[i];
			}
			else b[i]=0;
		}
		b[0]+=n;
		// C(b)
		for(i=0;i<26;i++){
			while(b[i]){
				c='a'+i;
				cout<<c;
				b[i]--;
			}
		}
		cout<<endl;
	}
}