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

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1e9;

bool beautifull(const vector<int>& cnt, int k) {
	for (int i : cnt) {
		if (i % k != 0)
			return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	int t;
	cin >> t;

	while (t--) {
		int n, k;
		cin >> n >> k;

		string s;
		cin >> s;


		if (n % k != 0) {
			cout << -1 << "\n";
			continue;
		}

		vector<int> cnt(26);
		for (int i = 0; i < n; ++i) {
			cnt[s[i] - 'a']++;
		}

		if (beautifull(cnt, k)) {
			cout << s << "\n";
			continue;
		}

		string ans;
		for (int i = n - 1; i >= 0; --i) {
			cnt[s[i] - 'a']--;

			for (char j = s[i] + 1; j <= 'z'; ++j) {
				cnt[j - 'a']++;

				int sum = 0;
				for (int c : cnt) {
					sum += (k - (c % k)) % k;
				}

				if (sum == (n - i - 1) || (sum < (n - i - 1) && (sum - (n - i - 1)) % k == 0)) {
					for (int q = 0; q < i; ++q) {
						ans += s[q];
					}
					ans += j;

					for (int q = 0; q < (n - i - 1) - sum; ++q) {
						ans += 'a';
					}

					for (int c = 0; c < 26; ++c) {
						for (int q = 0; q < (k - (cnt[c] % k)) % k; ++q) {
							ans += 'a' + c;
						}
					}

					break;
				}

				cnt[j - 'a']--;
			}

			if (!ans.empty())
				break;
		}
		
		cout << ans << "\n";
	}
}