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

/*
Antoni Dlugosz
VLO Krakow

"You know google - they ask you interview questions, well, the kind of question i face on the job is: 
"is this bad, is this too much voodoo for our purposes for our mission statement?". 
Our mission is to be a modern Commodore64, is this too much voodoo that, this is the op-, this, 
there is, this is voodoo, the question is "is this too much?" and that's, this is the hardest question 
you could ever face in programming.  This right here is the hardest question, right here, right here is the 
hardest question in programming, "is this too much voodoo for the next ten centuries?", as f-, for god's officlal temple, 
Holy, Holy C is the hardest question in programming, right here, okay, there it is, the hardest question in programming." 
 ~ the late Terry A. Davis
*/

//fast stuff
//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define mp        make_pair
#define eb        emplace_back
#define pb        push_back
#define e1        first
#define e2        second
#define vt        vector
#define size(x)   (int32_t)x.size()
#define all(r)    begin(r),end(r)
#define fastio    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define time      chrono::high_resolution_clock().now().time_since_epoch().count()
#define satori    int32_t TCS; cin>>TCS; while(TCS--)
#ifndef DEBUGMODE
#define DEBUGMODE false
#endif
#define debug     if(DEBUGMODE)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
	
template<typename T>
using ordset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int32_t main(){
	fastio;
	satori{
		int n,k;
		cin>>n>>k;
		string s;
		cin>>s;
		if(n%k!=0){
			cout<<"-1\n";
			continue;
		}
		vt<int> a(n);
		for(int i=0;i<n;i++)
			a[i]=s[i]-'a';
		vt<int> cnt(26,0);
		for(auto x:a)
			cnt[x]++;
		bool fail=false;
		for(auto x:cnt)
			if(x%k!=0)
				fail=true;
		if(!fail){
			cout<<s<<'\n';
			continue;
		}
		for(int i=n-1;i>=0;i--){
			cnt[a[i]]--;
			vt<int> cntf(26,0);
			for(int j=0;j<26;j++)
				if(cnt[j]%k!=0)
					cntf[j]=k-cnt[j]%k;
			int mx=-1;
			int sum=0;
			for(int j=0;j<26;j++)
				if(cntf[j])
					mx=j,sum+=cntf[j];
			if(sum>n-i)
				continue;
			if(sum!=n-i)
				mx=25;
			if(mx<=a[i])
				continue;
			string res;
			if(i!=0)
				res=s.substr(0,i);
			int smg=-1;
			for(int j=a[i]+1;j<26;j++)
				if(cntf[j]){
					smg=j;
					break;
				}
			if(smg==-1){
				smg=a[i]+1;
				cntf[smg]=k-1;
				sum+=k;
				while(sum!=n-i){
					sum+=k;
					cntf[0]+=k;
				}
			}
			else{
				cntf[smg]--;
				while(sum!=n-i){
					sum+=k;
					cntf[0]+=k;
				}
			}
			res.pb(((char)smg+'a'));
			for(int j=0;j<26;j++){
				while(cntf[j]){
					cntf[j]--;
					res.pb(((char)j+'a'));	
				}
			}
			assert(size(res)==size(s));
			cout<<res<<'\n';
			break;
		}
	}
	return 0;
}

/*
pointers on 64-bit environments take up 64 bits, not 32
vectors take up a lot of space
bitsets don't take up a lot of space
going out of bounds is bad
too much voodoo is bad
too much abstraction doesn't really impact performance in c++
abstraction is good
not returning in a non void function is bad
infinite loops are bad
overflow is bad
declaring stuff locally is good
cc_hash_table has faster queries, but considerably slower updates than gp_hash_table
overanalyzing stuff is good
assume nothing works correctly
don't do dumb stuff
speedrun writing slow solutions and generators at the start of the contest
remember to use pragmas :)
*/
