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>
using namespace std;

#define int long long int


void solve(void){
    int n,k; string s;
    cin >> n >> k >> s;
    if(n % k){
        cout << "-1\n";
        return;
    }
    map<char, int> mp;
    for(auto it : s){
        mp[it]++;
    }
    bool ok = true;
    for(char a = 'a' ; a <= 'z' ; a++){
        ok = ok and (mp[a] % k == 0);
    }
    if(ok){
        cout << s << "\n";
        return;
    }
    for(int i = n - 1 ; i >= 0 ; i--){
        mp[s[i]]--;
        for(char ch = s[i] + 1 ; ch <= 'z' ; ch++){
            mp[ch]++;
            int need = 0;
            for(char x = 'a' ; x <= 'z' ; x++){
                need += (k - mp[x] % k) % k;
            }
            if(n - i - 1 >= need){
                s[i] = ch;
                map<char,int> more;
                for(char ch = 'a' ; ch <= 'z' ; ch++){
                    more[ch] = (k - mp[ch] % k) % k;
                }
                for(int j = n - 1 ; j >= i + 1 ; j--){
                    s[j] = 'a';
                    for(char ch = 'z' ; ch >= 'a' ; ch -= 1){
                        if(more[ch] > 0){
                            more[ch]--;
                            s[j] = ch;
                            break;
                        }
                    }
                }
                cout << s << "\n";
                return;
            }
            mp[ch]--;
        }
    }
    return;
    
    
}

int32_t main(){
    int T = 1;
    cin >> T;
    while(T--) solve();
}
