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 INF 0x3f3f3f3f
#define pb push_back
using namespace std;
using LL = long long;
using pii = pair<int, int>;

inline int lowbit(int x) { return x & (-x); }
template <typename A>
inline A __lcm(A a, A b){ return a / __gcd(a, b) * b; }
template <typename A, typename B, typename C>
inline A fpow(A x, B p, C lyd) {
    A ans = 1;
    for(; p; p >>= 1, x = 1LL * x * x % lyd)if(p & 1)ans = 1LL * x * ans % lyd;
    return ans;
}

mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());

int T, n, k, freq[30];
string s, res;

inline int get(char c){
    return c - 'a';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin.exceptions(ios::badbit | ios::failbit);

    cin >> T;
    while(T --){
        res.clear();
        fill(freq, freq + 30, 0);
        cin >> n >> k >> s;
        if(n % k) cout << "-1" << endl;
        else{
            for(auto c: s) freq[get(c)] ++;
            bool ok = false, good = true;
            for(int i = 0; i < 26; i ++){
                if(freq[i] % k){
                    good = false;
                    break;
                }
            }
            if(good){
                cout << s << endl;
                continue;
            }
            for(int i = s.size() - 1; i >= 0; i --){
                freq[get(s[i])] --;
                int sum = 0;
                for(int j = 0; j < 26; j ++){
                    if(freq[j]) sum += (k - freq[j] % k) % k;
                }
                for(int j = s[i] + 1; j <= 'z'; j ++){
                    if(freq[get(j)]) sum -= (k - freq[get(j)] % k) % k;
                    freq[get(j)] ++;
                    sum += (k - freq[get(j)] % k) % k;
                    if(sum + i + 1 <= n){
                        for(int c = 25; c >= 0; c --){
                            if(freq[c]) for(int p = (k - freq[c] % k) % k; p > 0; p --) res.pb(c + 'a');
                        }
                        for(int c = n - sum - i - 1; c > 0; c --) res.pb('a');
                        res.pb(j);
                        for(int c = i - 1; c >= 0; c --) res.pb(s[c]);
                        ok = true;
                        break;
                    }
                    else{
                        sum -= (k - freq[get(j)] % k) % k;
                        freq[get(j)] --;
                        if(freq[get(j)]) sum += (k - freq[get(j)] % k) % k;
                    }
                }
                if(ok) break;
            }
            reverse(res.begin(), res.end());
            cout << res << endl;
        }
    }

    return 0;
}
