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<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;

int n, m;
string str;
int prefix[100010][26];

string check(int idx)
{
	int cnt;
	int i, j;
	string ret;

	cnt = str.length() - idx;
	for (i = 0; i < 26; i++)
	{
		cnt -= (m - (prefix[idx][i] % m)) % m;
	}

	if (cnt < 0) return "#";

	while (cnt--)
	{
		ret += 'a';
	}
	for (i = 0; i < 26; i++)
	{
		for (j = 0; j < (m - (prefix[idx][i] % m)) % m; j++)
		{
			ret += (char)(i + 'a');
		}
	}

	return ret;
}

string check2(int idx)
{
	int i, j;
	string ret;
	string ans;

	for (i = str[idx] - 'a' + 1; i < 26; i++)
	{
		prefix[idx + 1][str[idx] - 'a']--;
		prefix[idx + 1][i]++;
		ret = check(idx + 1);
		if (ret.compare("#") != 0)
		{
			for (j = 0; j < idx; j++) ans += str[j];
			ans += (char)(i + 'a');
			return ans + ret;
		}
		prefix[idx + 1][i]--;
		prefix[idx + 1][str[idx] - 'a']++;
	}

	return "#";
}

int main()
{
	int t;
	int i, j;
	string ans;

	cin >> t;
	while (t--)
	{
		cin >> n >> m;
		cin >> str;

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

		for (i = 0; i < str.length(); i++)
		{
			for (j = 0; j < 26; j++)
			{
				prefix[i + 1][j] = prefix[i][j];
			}

			prefix[i + 1][str[i] - 'a']++;
		}

		ans = check(str.length());
		if (ans.compare("#") != 0)
		{
			cout << str << '\n';
			continue;
		}
		for (i = str.length() - 1; i >= 0; i--)
		{
			ans = check2(i);
			if (ans.compare("#") != 0)
			{
				cout << ans << '\n';
				break;
			}
		}

		if (ans.compare("#") == 0)
		{
			cout << -1 << '\n';
		}
	}
}