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 <bits/stdc++.h>
//#define int long long
//#define INT_MAX INT64_MAX
//#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcountll
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
            prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
    factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
void solve(){
    int n, k;
    cin >> n >> k;
    string str = "";
    cin >> str;
    int pre[26][n];
    bool fg = true;
    for(int i=0; 26>i; i++){
        int sm = 0;
        for(int j=0; n>j; j++){
            if(str[j]-'a' == i){
                sm++;
            }
            pre[i][j] = sm%k;
        }
        if(pre[i][n-1] != 0){
            fg = false;
        }
    }
    //Check if input is valid!!!
    if(fg){
        cout << str << endl;
        return;
    }
    for(int j=n-1; j>=0; j--){
        for(int c=str[j]-'a'+1; 26>c; c++){
            int freq[26];
            if(j > 0){
                for(int i=0; 26>i; i++){
                    freq[i] = pre[i][j-1];
                    
                }
            }else{
                memset(freq, 0, sizeof(freq));
            }
            freq[c]++;
            freq[c] %= k;
            int remLength = n-j-1;
            int temp = 0;
            for(int i=0; 26>i; i++){
                if(freq[i] > 0){
                    temp += (k-freq[i]);
                }
            }
            if(temp <= remLength){
                // possible answer
                string extra = "";
                for(int i=0; 26>i; i++){
                    if(freq[i] > 0){
                        int ap = k-freq[i];
//                        cout << j << ' ' << k << ' ' << i << ' ' <<freq[i] << endl;
                        while(ap--){
                            extra.push_back(i+'a');
                        }
                    }
                }
                int rem = remLength - temp;
                if(rem%k == 0){
                    while(rem--){
                        extra.push_back('a');
                    }
                    sort(extra.begin(), extra.end());
//                    cout << '*' << j << ' ' << c  << endl;
                    for(int i=0; j>i; i++){
                        cout << str[i];
                    }
                    cout << (char)(c+'a');
                    cout << extra << endl;
                    return;
                }
                
            }
        }
    }
    cout << -1 << endl;
}
signed main(){
    fastio;
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}





