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 <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <unordered_map>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

stringstream out;

void solveTest()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	if (n % k != 0)
	{
		out << "-1\n";
		return;
	}
	vector<int> groups(26 + 'a');
	string newstr(n, '0');
	int z = 0;
	bool e = true;
	int i;
	for (i = 0; i < n && e; i++)
	{
		char c = s[i];
		if (groups[c] % k != 0)
		{
			groups[c]++;
			newstr[i] = c;
		}
		else if (z < n / k)
		{
			groups[c]++, z++;
			newstr[i] = c;
		}
		else
		{
			do
			{
				for (char a = c + 1; a <= 'z'; a++)
				{
					if (groups[a] % k != 0)
					{
						groups[a]++;
						newstr[i] = a;
						e = false;
						break;
					}
					else if (z < n / k)
					{
						groups[a]++, z++;
						newstr[i] = a;
						e = false;
						break;
					}
				}
				if (!e)
					break;
				i--;
				c = newstr[i];
				if (--groups[c] % k == 0)
					z--;
			} while (e && i >= 0);
		}
	}
	while (z < n / k)
	{
		if (groups['a']++ % k == 0)
			z++;
		newstr[i++] = 'a';
	}
	for (char c = 'a'; i < n; i++) // 'c'
	{
		if (groups[c] % k == 0)
			c++, i--;
		else
		{
			groups[c]++;
			newstr[i] = c;
		}
	}
	out << newstr << '\n';
}

int main()
{
	int tests = 1;
	cin >> tests;
	while (tests--)
		solveTest();
	cout << out.str();
	return 0;
}