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 optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
 
#define f(i,a,b) for(ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for(ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll  i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for(ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sz(a) (ll) a.size()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller   ios::sync_with_stdio(false);cin.tie(0)
 
// policy-based
 
 
 
 
using namespace std;
 
typedef int ll; // ll or ll
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 2e5 + 20;
const ll mod = 1e9 + 7;
const ll inf = 2e9;


ll cur[26];

int main(){ 
	fastio;
	ll tc,n,k;
	string s;
	cin >> tc;
	while(tc--){
		cin >> n >> k >> s;
		f(i,0,26) cur[i] = 0;
		if(n%k != 0){
			cout << "-1\n";
			continue;
		}
		bool go = false;
		f(i,0,n) cur[s[i]-'a']++;
		bool g = true;
		f(i,0,26) if(cur[i]%k != 0) g = false;
		if(g){
			cout << s << endl;
			continue;
		}
		af(i,n-1,0){
			cur[s[i]-'a']--;
			f(j,s[i]-'a' + 1,26){
				cur[j]++;
				ll res = 0;
				f(d,0,26) res += (cur[d]%k == 0? 0: k - cur[d]%k);
				if(res <= n-1-i){
					
					go = true;
					string aux = "";
					f(x,0,n-1-i-res) aux.push_back('a');
					f(x,0,26){
						if(cur[x]%k > 0)
							f(y,0,k-cur[x]%k) aux.push_back('a' + x);
					}
					s[i] = 'a' + j;
					s = s.substr(0,i+1) + aux;
					go = true;
					break;
				}
				cur[j]--;
			} 
			if(go) break;
		}

		if(go) cout << s << endl;
		else cout <<"-1\n"; 
	}
	return 0;
}
