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

#pragma GCC target("avx")
#include <bits/stdc++.h>

using namespace std;

//Template ver. 0.3.2

#define F first
#define S second
#define TC for(int _t_,_q_=0,__=scanf("%d",&_t_);_q_<_t_;_q_++)
#define ALL(iter) begin(iter),end(iter)

#define RANDMN 0
#define RANDMX INT32_MAX

template<class T, class S>
ostream& operator<<(ostream& s, pair<T,S> &p){s<<'{'<<p.F<<", "<<p.S<<'}';return s;}

template<class T>
ostream& operator<<(ostream& s, vector<T> &v){if(v.empty()){s<<"[]";return s;}
	s <<'[';for(int i=0;i<v.size()-1;i++){s<<v[i]<<", ";}s<<v.back()<<']';return s;}

static mt19937 random_gen(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(){
	static uniform_int_distribution<int> uid(RANDMN, RANDMX);
	return uid(random_gen);
}

typedef uint8_t  u8;
typedef uint64_t u64;
typedef int64_t  s64;

typedef pair<int, int> pii;
typedef pair<s64, s64> pll;

template<size_t S>
inline array<int, S> operator+(const array<int, S> &a, const array<int, S> &b){
	array<int, S> c = a;
	for(int i = 0; i < S; i++){
		c[i] += b[i];
	}
	return c;
}

template<size_t S>
inline void operator+=(array<int, S> &a, const array<int, S> &b){
	for(int i = 0; i < S; i++){
		a[i] += b[i];
	}
	return;
}

template<size_t S>
inline void operator%=(array<int, S> &a, const int v){
	for(int i = 0; i < S; i++){
		a[i] %= v;
	}
	return;
}

template<size_t S>
inline array<int, S> operator%(const array<int, S> &a, const int v){
	array<int, S> c = a;
	c %= v;
	return c;
}

template<size_t S>
inline void operator/=(array<int, S> &a, const int v){
	for(int i = 0; i < S; i++){
		a[i] = (a[i]+v-1)/v;
	}
	return;
}

template<size_t S>
inline array<int, S> operator/(const array<int, S> &a, const int v){
	array<int, S> c = a;
	c /= v;
	return c;
}

#define MAXN 100005
#define LALPH 26

char inp[MAXN];

array<int, LALPH> psm[MAXN];

int main(){
	TC{
		int n, k;
		scanf("%d%d%100001s", &n, &k, inp+1);
		if(n % k){
			puts("-1");
			continue;
		}
		for(int i = 1; i <= n; i++){
			psm[i] = psm[i-1];
			psm[i][inp[i]-'a']++;
		}
		auto pr = psm[n] % k;
		if(pr == psm[0]){
			printf("%s\n", inp+1);
			continue;
		}
		char diff = 0;
		int mxl = 0;
		for(int i = n; i > 0; i--){
			bool ok = false;
			for(int j = inp[i]-'a'+1; j < LALPH; j++){
				auto arr = psm[i-1];
				arr[j]++;
				arr /= k;
				int sm = 0;
				for(auto x:arr){
					sm += x * k;
				}
				if(sm > n){
					continue;
				} else {
					ok = true;
					diff = 'a' + j;
					mxl = i;
					break;
				}
			}
			if(ok){
				break;
			}
		}
		assert(diff);
		assert(mxl);
		int rem = n;
		array<int, LALPH> resv;
		array<int, LALPH> prnt;
		fill(ALL(resv), 0);
		fill(ALL(prnt), 0);
		for(int i = 1; i < mxl; i++){
			int pos = inp[i] - 'a';
			prnt[pos]++;
			if(prnt[pos] > resv[pos]){
				resv[pos] += k;
				rem -= k;
			}
			printf("%c", inp[i]);
		}
		{
			int pos = diff - 'a';
			prnt[pos]++;
			if(prnt[pos] > resv[pos]){
				resv[pos] += k;
				rem -= k;
			}
			printf("%c", diff);
		}
		for(int i = mxl+1; i <= n; i++){
			if(resv[0] > prnt[0]){
				prnt[0]++;
				printf("a");
				continue;
			}
			if(rem){
				rem -= k;
				resv[0] += k;
				prnt[0]++;
				printf("a");
				continue;
			}
			for(int i = 1; i < LALPH; i++){
				if(resv[i] > prnt[i]){
					prnt[i]++;
					printf("%c", 'a' + i);
					break;
				}
			}
		}
		puts("");
	}
	return 0;
}
