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

// Nurstan Duisengaliev(REALBOY)
// не, не надо меня узнавать 
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")*/                   
      
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define pll pair <ll, ll>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 1;
int n, k;
string s;
int cnt[30];
bool check (int x) {
    memset (cnt, 0, sizeof cnt);
	for (int i = 0; i < x; i ++) {
		cnt[s[i] - 'a'] ++;
	}
	for (int i = s[x] - 'a' + 1; i <= 25; i ++) {	
		cnt[i] ++;
		int sum = 0;
		for (int j = 0; j <= 25; j ++) {
			if (cnt[j] % k != 0) {
				sum += (cnt[j] + k - 1) / k * k - cnt[j];
			}		
		}
		if (sum <= sz (s) - 1 - x && (sz (s) - 1 - x - sum) % k == 0) return 1;
		cnt[i] --;
	}
	return 0;
}
void solve () {
	cin >> n >> k >> s;
	for (auto it : s) {
		cnt[it - 'a'] ++;
	}
	bool yes = 1;
	for (int i = 0; i <= 25; i ++) {
		if (cnt[i] % k != 0) {
			yes = 0;
			break;
		}
	}
	if (yes) {
		cout << s << endl;
		return;
	}
	memset (cnt, 0, sizeof cnt);
	int l = 0, r = sz (s) - 1, o = -1;
	while (l <= r) {
		int mid = l + r >> 1;
		if (check (mid)) {
			o = mid;
			l = mid + 1;		
		}
		else r = mid - 1;
	}
	if (o == -1) {
		cout << -1 << endl;
		return;
	}
	string ans = "";
	memset (cnt, 0, sizeof cnt);
	for (int i = 0; i < o; i ++) {
		cnt[s[i] - 'a'] ++;
		ans += s[i];
	}
	for (int i = s[o] - 'a' + 1; i <= 25; i ++) {	
		cnt[i] ++;
		int sum = 0;
		for (int j = 0; j <= 25; j ++) {
			if (cnt[j] % k != 0) {
				sum += (cnt[j] + k - 1) / k * k - cnt[j];
			}		
		}
		if (sum <= sz (s) - 1 - o && (sz (s) - 1 - o - sum) % k == 0) {
			ans += char (i + 'a');
			for (int j = 0; j <= 25; j ++) {
				int O = (cnt[j] + k - 1) / k * k - cnt[j];
				while (O --) {
					ans += char ('a' + j);
				}	
			}
			int O = (sz (s) - 1 - o - sum);
			while (O --) ans += 'a';
			break;
		}
		cnt[i] --;
	}
	cout << ans << '\n';
}   	                     
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT;
    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	                                    
}