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;
const int maxn=1e6+7;
const int inf=2e9;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

int n,k,need=0;
int cnt[27];

void add(int x) {
	need-=(cnt[x]%k==0 ? 0 : k-cnt[x]%k);
	cnt[x]++; 
	need+=(cnt[x]%k==0 ? 0 : k-cnt[x]%k);
}

void sub(int x){
	need-=(cnt[x]%k==0 ? 0 : k-cnt[x]%k);
	cnt[x]--; 
	need+=(cnt[x]%k==0 ? 0 : k-cnt[x]%k);

}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t; cin>>t;
	while (t--) {
		cin>>n>>k;
		string s; cin>>s;
		if (n%k!=0) {
			cout<<"-1\n";
			continue;
		}

		memset(cnt,0,sizeof(cnt));
		need=0;
		for (int i=0;i<n;i++) add(s[i]-'a');
		if (need==0) {
			cout<<s<<'\n';
			continue;
		}
		string ans="";
		for (int i=n-1;i>=0;i--) {
			if (ans!="") break;
			sub(s[i]-'a');
			for (int j=s[i]-'a'+1;j<26;j++) {
				add(j);
				if (need<=(n-1)-i) {
					string tmp;
					for (int kk=0;kk<i;kk++) ans.pb(s[kk]);
					ans.pb(j+'a');
					for (int kk=0;kk<26;kk++)
						if (cnt[kk]%k!=0) tmp+=string(k-cnt[kk]%k,kk+'a');
					while (sz(tmp)+sz(ans)<n) tmp.pb('a');
					sort(all(tmp));
					ans+=tmp;

					break;
				}
				sub(j);
			}
		}
		cout<<ans<<'\n';
	}
}
