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;
#define ll int long long
#define mp make_pair
//#define for(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define N 1000000007
#define pq priority queue
#define pb push_back
#define pf push_front
#define mt make_tuple
#define prec(a) fixed<<setprecision(9)<<a
#define endl "\n"
#define fast_set s.max_load_factor(0.25);s.reserve(500);
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
const long double PI = (long double)(3.1415926535897932384626433832795);
bool check(int a,int b,int hh,int mm)
{
	
	int savea=a,saveb=b;
	int arr[10];
	memset(arr,-1,sizeof(arr));
	arr[0]=0;
	arr[1]=1;
	arr[2]=5;
	arr[5]=2;
	arr[8]=8;
	int h=0,m=0;
	h=arr[(b%10)]*10+arr[(b/10)];
	m=arr[(a%10)]*10+arr[(a/10)];
	if(arr[a%10] == -1 || arr[a/10] == -1 || arr[b%10] == -1 || arr[b/10] == -1){
		return 0;
	}
	return (h<hh&&m<mm);
}
int main() 
{
	fast;
	int test,n,i,j,k;
	cin>>test;
	while(test--)
	{
		string str;
		cin>>n>>k>>str;
		if(n%k!=0)
		{
			cout<<"-1"<<endl;
		}
		else
		{
			int hash1[26]={0};
			n=str.length();
			for(i=0;i<n;i++)
			{
				hash1[str[i]-'a']++;
			}
			for(i=0;i<26;i++)
			{
				if(hash1[i]%k!=0)
				{
					break;
				}
			}
			if(i==26)
			{
				cout<<str<<endl;
			}
			else
			{
				for(i=n-1;i>=0;i--)
				{
					hash1[str[i]-'a']--;
					for(j=str[i]-'a'+1;j<26;j++)
					{
						bool flag=1;
						hash1[j]++;
						int it=0,cnt=0;
						for(it=0;it<26;it++)
						{
							cnt+=((k-(hash1[it]%k))%k);
						}
						int avail = n-i-1;
						if(cnt>avail||(avail-cnt)%k!=0)
						{
							flag=0;
						}
						hash1[j]--;
						if(flag)
						{
							break;
						}
					}
					if(j<26)
					{
						break;
					}
				}
				if(i<0)
				{
					cout<<i<<endl;
				}
				else
				{
					//cout<<i<<" "<<j<<endl;
					str[i]='a'+j;
					hash1[j]++;
					int it=0,mini=0;
					vector<int>s;
					int sum=0;
					for(it=0;it<26;it++)
					{
						if(hash1[it]>0)
							mini=min(mini,it);
						int a=((k-(hash1[it]%k))%k);
						sum+=a;
						while(a--)
						{
							mini=min(mini,it);
							s.pb(it);
						}
					}
					//cout<<sum<<endl;
					int a=n-i-1-sum;
					while(a--)
					{
						s.pb(mini);
					}
					int c=0;
					//cout<<s.size()<<endl;
					sort(all(s));
					for(j=i+1;j<n;j++)
					{
						str[j]='a'+s[c];
						c++;
						
					}
					cout<<str<<endl;
				}
			}
		}
	}
	return 0;
}





