#include <iostream>
#include <set>

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t;
    std::cin >> t;
    while (t--) {
        int n, k;
        std::string s;
        std::cin >> n >> k >> s;
        if (n % k != 0) {
            std::cout << -1 << '\n';
            continue;
        }
        int last_index = -1, last_index_2 = -1, not_used = n / k;
        char ans;
        std::multiset<char> used;
        std::string new_s;
        for (int i = 0; i < n; ++i) {
            auto it = used.lower_bound(s[i]);
            if (it != used.end() && *it == s[i]) {
                if (s[i] < *(--used.end())) {
                    last_index_2 = i;
                    ans = *used.upper_bound(s[i]);
                }
                new_s.push_back(s[i]);
                used.erase(it);
                continue;
            }
            if (not_used != 0) {
                --not_used;
                if (s[i] != 'z') {
                    last_index = i;
                }
                new_s.push_back(s[i]);
                for (int j = 0; j < k - 1; ++j) {
                    used.insert(s[i]);
                }
                continue;
            }
            if (it != used.end()) {
                new_s.push_back(*it);
                used.erase(it);
                break;
            }
            used.clear();
            new_s.clear();
            not_used = n / k;
            if (last_index > last_index_2) {
                s[last_index] = s[last_index] + 1;
                for (int j = 0; j <= last_index; ++j) {
                    new_s.push_back(s[j]);
                    it = used.lower_bound(s[j]);
                    if (it != used.end() && *it == s[j]) {
                        used.erase(it);
                    } else {
                        for (int l = 0; l < k - 1; ++l) {
                            used.insert(s[j]);
                        }
                        --not_used;
                    }
                }
            } else {
                s[last_index_2] = ans;
                for (int j = 0; j <= last_index_2; ++j) {
                    new_s.push_back(s[j]);
                    it = used.lower_bound(s[j]);
                    if (it != used.end() && *it == s[j]) {
                        used.erase(it);
                    } else {
                        for (int l = 0; l < k - 1; ++l) {
                            used.insert(s[j]);
                        }
                        --not_used;
                    }
                }
            }
            break;
        }
        std::cout << new_s;
        std::cout << std::string(not_used * k, 'a');
        for (char x : used) {
            std::cout << x;
        }
        std::cout << '\n';
    }
    return 0;
}

