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;
using gg = long long;
// constexpr gg MAX = 20;
constexpr gg MAX = 1e6 + 5;
constexpr gg mod = 1e9 + 7;
constexpr gg INF = 2e18;
constexpr double thre = 1e-7;
gg ti, ni, mi, ki, di, pi, xi, yi;
inline gg g(gg n) { return (n + ki - 1) / ki * ki; }
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ti = 1;
    cin >> ti;
    while (ti--) {
        string s;
        cin >> ni >> ki >> s;
        if (ni % ki != 0) {
            cout << -1 << "\n";
            continue;
        }
        map<char, gg> m;
        for (char c : s) {
            m[c]++;
        }
        bool f = true;
        for (auto& [i, j] : m) {
            if (j % ki != 0) {
                f = false;
                break;
            }
        }
        if (f) {
            cout << s << "\n";
            continue;
        }
        m.clear();
        gg ans = -1, c = 0;
        for (gg i = 0; i < ni; ++i) {
            bool f = false;
            for (auto& [k1, k2] : m) {
                if (k1 > s[i] and g(k2) > k2) {
                    f = true;
                    break;
                }
            }
            if (s[i] != 'z' and (c < ni / ki or f)) {
                ans = i;
            }
            if (m[s[i]] % ki == 0) {
                ++c;
            }
            m[s[i]]++;
            if (c > ni / ki) {
                break;
            }
        }
        m.clear();
        c = 0;
        string res = s.substr(0, ans);
        for (gg i = 0; i < ans; ++i) {
            if (m[s[i]] % ki == 0) {
                ++c;
            }
            m[s[i]]++;
        }
        if (c < ni / ki) {
            res.push_back(s[ans] + 1);
            if (m[s[ans] + 1] % ki == 0) {
                ++c;
            }
            m[s[ans] + 1]++;
        } else {
            for (auto& [k1, k2] : m) {
                if (k1 > s[ans] and g(k2) > k2) {
                    k2++;
                    res.push_back(k1);
                    break;
                }
            }
        }
        string temp;
        for (auto& [k1, k2] : m) {
            temp += string(g(k2) - k2, k1);
        }
        temp += string(ki * (ni / ki - c), 'a');
        sort(temp.begin(), temp.end());
        cout << res + temp << "\n";
    }
    return 0;
}