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<unordered_map>
#include<algorithm>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<stdio.h>
#include<vector>
#include<string>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll ll_inf = 9223372036854775807;
const int int_inf = 2147483647;
const short short_inf = 32767;
const ll less_inf = 0x3f3f3f3f;
const char char_inf = 127;
#pragma GCC optimize(2)
#define accelerate cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false);
#define PI 3.141592653589793
#define EPS 1.0e-8
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
inline ll read() {
	ll c = getchar(), Nig = 1, x = 0;
	while (!isdigit(c) && c != '-')c = getchar();
	if (c == '-')Nig = -1, c = getchar();
	while (isdigit(c))x = ((x << 1) + (x << 3)) + (c ^ '0'), c = getchar();
	return Nig * x;
}
inline void out(ll a) {
	if (a < 0)putchar('-'), a = -a;
	if (a > 9)out(a / 10);
	putchar(a % 10 + '0');
}
ll qpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}
#define read read()
char save[100005];
int cnt[128];
int main()
{
	int T = read;
	while (T--)
	{
		memset(cnt, 0, sizeof(cnt));
		int sum = 0;
		int n = read, m = read;
		scanf("%s", save);
		for (int i = 0; save[i]; i++)cnt[save[i]]++;
		for (int i = 'a'; i <= 'z'; i++)
			sum += (m - cnt[i] % m) % m;
		if (sum == 0)puts(save);
		else if (sum % m)puts("-1");
		else
		{
			for (int i = n - 1; i >= 0; i--)
			{
				sum -= (m - cnt[save[i]]-- % m) % m;
				sum += (m - cnt[save[i]] % m) % m;
				for (int j = save[i] + 1; j <= 'z'; j++)
				{
					int LastSum = sum;
					sum -= (m - cnt[j]++ % m) % m;
					sum += (m - cnt[j] % m) % m;
					if (i + 1 + sum <= n)
					{
						for (int k = 0; k < i; k++)putchar(save[k]);
						putchar(j);
						if (i + 1 + sum < n)
							for (int k = i + 1 + sum; k < n; k++)
								putchar('a');
						for (char k = 'a'; k <= 'z'; k++)
						{
							int tot = (m - cnt[k] % m) % m;
							while (tot--)putchar(k);
						}
						puts("");
						goto END;
					}
					else cnt[j]--, sum = LastSum;
				}
			}
		}
	END:;
	}
}
/*
1
9 3
abaabaaaa
*/