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 pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }

template<class T> void DBG(T&& x) { cerr << x << " "; }
template<class T, class...Args> void DBG(T&& x, Args&&... args) { DBG(x); DBG(args...); }
#define DBG(...) { cerr << "[" << #__VA_ARGS__ << "]: "; DBG(__VA_ARGS__); cerr << endl; }
template<class num> inline void rd(num& x) { cin >> x; }
template <class Ty, class... Args> inline void rd(Ty& x, Args&... args) { rd(x); rd(args...); }
template<class num> inline void print(num&& x) { cout << x; }
template <class Ty, class... Args> inline void print(Ty&& x, Args&&... args) { print(x); print(' '); print(args...); }
#define print(...) print(__VA_ARGS__), print('\n')

bool valid(string const& s, int k) {
	int f[26] = {};
	for (char c : s) f[c-'a']++;
	for (int i = 0; i < 26; i++) if (f[i]%k) return false;
	return true;
}

inline void run_test(int test_number) {
	int n, k; rd(n, k);
	string s; rd(s);

	if (n % k) {
		print(-1);
		return;
	}

	if (valid(s, k)) {
		print(s);
		return;
	}

	vector<int> f(26);
	pii where = {-1, -1};
	for (int i = 0; i < n; i++) {
		for (int cur = 25; cur >= s[i]-'a'+1; cur--) {
			f[cur]++;
			int left = n - i - 1;
			for (int c = 25; c >= 0; c--) {
				left -= (k - (f[c] % k)) % k;
			}
			f[cur]--;
			if (left >= 0) where = {i, cur};
		}

		f[s[i]-'a']++;
	}

	assert(where.fi != -1);

	f.assign(26, 0);
	for (int i = 0; i < where.fi; i++) f[s[i]-'a']++;
	f[where.se]++;

	int i = where.fi;
	int j = n - 1;
	for (int c = 25; c >= 0; c--) {
		int much = (k - (f[c] % k)) % k;
		for (int qt = 0; qt < much; qt++) s[j--] = c + 'a';
	}
	for (int ii = i + 1; ii <= j; ii++) s[ii] = 'a';
	s[i] = where.se + 'a';
	print(s);
}

int main() {

//#ifndef LOCAL_PC
//	freopen("FILE.in", "r", stdin);
//#endif

	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n_tests = 1;
	rd(n_tests);
	for (int i = 1; i <= n_tests; i++) run_test(i);
}