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 endl "\n"
#define int long long
#define debug(var) \
    if (debugging) \
    cerr << (#var) << ": " << var << endl

const bool debugging = 1;
const int mod = 1e9 + 7;

using namespace std;

template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
    for (auto v : V)
    {
        os << char(v + 'a');
    }
    return os << "";
}

template <class T>
ostream &operator<<(ostream &os, vector<vector<T>> V)
{
    for (int i = 0; i < V.size(); i++)
    {
        for (int j = 0; j < V[i].size(); j++)
        {
            os << V[i][j] << " ";
        }
        os << endl;
    }
    return os << "";
}

template <class T>
ostream &operator<<(ostream &os, set<T> S)
{
    for (auto s : S)
    {
        os << s << " ";
    }
    return os << "";
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
    return os << P.first << " " << P.second;
}

template <class L, class R>
ostream &operator<<(ostream &os, map<L, R> M)
{
    os << endl;
    for (auto m : M)
    {
        os << m << endl;
    }
    return os << "";
}

// // cout << needed << endl;

// vector<int> temp_ans;
// bool useful_corner = 0;
// vector<int> corner;
// auto it = needed.upper_bound(val);
// if (it != needed.end())
// {
//     need--;
//     needed[(*it).first]--;
//     corner.push_back((*it).first);
//     if (free >= need)
//     {
//         if ((free - need) % K == 0)
//         {
//             needed[0] += free - need;
//             index = i;
//             for (auto &X : needed)
//             {
//                 for (int i = 0; i < X.second; i++)
//                 {
//                     corner.push_back(X.first);
//                 }
//             }
//             cout << corner << endl;
//             useful_corner = 1;
//         }
//     }
//     need++;
//     needed[(*it).first]++;
// }

// // int initial_need = 0;
// // if (count[val + 1] % K != 0)
// // {
// //     int temp = K - count[val + 1] % K;
// //     initial_need += temp;
// // }

// // temp_ans.push_back(val + 1);
// // need--;
// // needed[val + 1]--;

// // int final_need = 0;
// // if (count[val + 1] % K != 0)
// // {
// //     int temp = K - count[val + 1] % K;
// //     initial_need += temp;
// // }

// // // cout << needed << endl;

void solve()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> count(26);
    bool initial = 1;
    for (int i = 0; i < N; i++)
    {
        count[S[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++)
    {
        if (count[i] % K != 0)
        {
            initial = 0;
        }
    }

    if (initial)
    {
        cout << S << endl;
        return;
    }

    //cout << count << endl;
    int free = 0;
    int index = -1;
    vector<int> ans;
    for (int i = N - 1; i >= 0; i--)
    {
        int val = S[i] - 'a';
        count[val]--;
        if (val == 25)
        {
            free++;
            continue;
        }

        int need = 0;
        map<int, int> needed;
        for (int j = 0; j < 26; j++)
        {
            if (count[j] % K != 0)
            {
                int temp = K - count[j] % K;
                need += temp;
                needed[j] = temp;
            }
        }

        vector<int> temp;
        int contri_before = (K - count[val + 1] % K) % K;
        int contri_after = (K - (count[val + 1] + 1) % K) % K;
        need += (contri_after - contri_before);
        needed[val + 1] += (contri_after - contri_before);
        temp.push_back(val + 1);
        // TODO: Handle current element

        if (free >= need)
        {
            if ((free - need) % K == 0)
            {
                needed[0] += free - need;
                index = i;
                for (auto &X : needed)
                {
                    for (int i = 0; i < X.second; i++)
                    {
                        temp.push_back(X.first);
                    }
                }
                ans = temp;
                break;
            }
        }

        needed.clear();
        need = 0;
        for (int j = 0; j < 26; j++)
        {
            if (count[j] % K != 0)
            {
                int temp = K - count[j] % K;
                need += temp;
                needed[j] = temp;
            }
        }
        auto it = needed.upper_bound(val);
        if (it != needed.end())
        {
            temp.clear();
            need--;
            needed[(*it).first]--;
            temp.push_back((*it).first);
            // cout << temp << endl;
            if (free >= need)
            {
                if ((free - need) % K == 0)
                {
                    needed[0] += free - need;
                    index = i;
                    for (auto &X : needed)
                    {
                        for (int i = 0; i < X.second; i++)
                        {
                            temp.push_back(X.first);
                        }
                    }
                    ans = temp;
                    break;
                }
            }
        }
        free++;
    }

    if (index == -1)
    {
        cout << -1 << endl;
        return;
    }

    for (int i = 0; i < index; i++)
    {
        cout << S[i];
    }
    cout << ans << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int no_of_testcases;
    cin >> no_of_testcases;
    while (no_of_testcases-- > 0)
    {
        solve();
    }
    return 0;
}