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 <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cstring>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>
#include <limits>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX 2000000000ll
#define F(a, b) f[a + 1][b + 1]
#define SetBreak(a, b) if (i == a && j == b)
#define eps 1e-9
#define CLOCKS_PER_SECOND ((clock_t)1000)
#define ll_max numeric_limits<long long>::max();
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define Access(v, pos) (((v) >> (pos)) & 1)
#define ValidPos(a,b) ((a) >= 0 && (a) < n && (b) >= 0 && (b) < m) 
#define Serialize(a,b) ((a) * m + (b))
#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )
#define Fork(i,j,k) for( int (i) = (k) ; (i) <= (j) ; ++(i) )
#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )
#define For0k(i,j,k) for( int (i) = (k); (i) < (j) ; ++(i) )

typedef long long ll;
typedef vector<int> vci;
typedef pair<int, int> pii;
template <typename T> void UpdateMax(T& a, T b) {if (a < b) a = b;}
template <typename T> void UpdateMin(T& a, T b) {if (a > b) a = b;}
template<typename T>
inline void read(T &x)
{
    x = 0; char c = getchar(); int flag = 1;
    while(!isdigit(c)) {if (c == '-') flag = -1; c = getchar();}
    while(isdigit(c)) {x = x * 10 + c - '0'; c = getchar();}
    x *= flag;
}
template<typename T>
void Unique(vector<T>& vec)
{
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
template<typename T>
void Relabel(vector<T>& vec, T& value)
{
    value = lower_bound(vec.begin(), vec.end(), value) - vec.begin() + 1;
}
template <typename T, typename V> void Print(const pair<T, V>& x) { cout<<x.first<<" @ "<<x.second<<" | "; }
template <typename T> void Print(const T& x) { cout<<x<<" ";  }
template <typename T> void Pcon(const T& x) { cout<<"\nsize: "<<x.size()<<endl; for (const auto& item : x) Print(item); }
std::vector<int> LABS;
template <typename T> void Print(const T* x, int offset, int loop)
{
    for (int i = 0; i <= loop; i++)
    {
        cout<<"[";
        for (int item : LABS)
            cout<<item - offset<<",";
        cout<<i - offset<<"]:";
        cout<<x[i]<<" ";
    }
}
template <typename T, typename... Args>
void Print(const T* f, int offset, int loop, Args... args)
{
    for (int i = 0; i <= loop; i++)
    {
        LABS.push_back(i);
        Print(f[i], offset, args...);
        cout<<endl;
        LABS.pop_back();
    }
}
template <typename T, typename V>
bool Has(T& cluster, const V& item)
{
    return cluster.find(item) != cluster.end();
}
int Logn(ll x) { int cnt = 0; while (x) { ++cnt; x >>= 1; } return cnt; }
//////////////////////////////////////////////////////
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {1, 0}};
struct Edg {int x, y, z;friend bool operator < (const Edg& lhs, const Edg& rhs){return lhs.z < rhs.z;}} edg[N];
bool vis[N], used[N];
clock_t start_time;
int t, n, m;
int f[26];
vci G[N];
//////////////////////////////////////////////////////
inline void SetClock() { start_time = clock(); }
bool TimeOut(size_t ms) { if (1000*(clock() - start_time) >= ms * CLOCKS_PER_SECOND) return true; return false; }
inline pii DeSerialize(int c) { return {(c) / m, (c) % m}; }
template <typename T, typename V>
inline void Add(T& v, const V& delta) { v += delta; if (v >= MOD) v -= MOD; }
template <typename T, typename V>
inline void Dec(T& v, const V& delta) { v -= delta; if (v < 0) v += MOD; }
//////////////////////////////////////////////////////
int T, k;
string s;
bool check(int left) {
    for (int i = 0; i < 26; ++i) {
        left -= (k - (f[i] % k)) % k;
        if (left < 0) {
            return false;
        }
    }
    return left % k == 0;
}
int main()
{
    srand(time(0));
    SetClock();
    cin.sync_with_stdio(false);
    //freopen("test.in", "r", stdin);
    cin>>T;
    while (T--) {
        cin>>n>>k;
        cin>>s;        
        if (n % k != 0) {
            cout<<-1<<endl;
            continue;
        }
        memset(f, 0, sizeof(f));
        for (int i = 0; i < n; ++i) {
            ++f[s[i] - 'a'];
        }
        if (check(0)) {
            cout<<s<<endl;
            continue;
        }
        int cursor = -1;
        for (int i = n - 1; i >= 0 && cursor == -1; --i) {
            --f[s[i] - 'a'];
            for (char j = s[i] + 1; j <= 'z'; ++j) {
                ++f[j - 'a'];
                if (check(n - i - 1)) {
                    cursor = i;
                    s[i] = j;
                    break;
                }
                --f[j - 'a'];
            }            
        }
        if (cursor == -1) {
            cout<<-1<<endl;
            continue;
        }        
        for (int i = cursor + 1; i < n; ++i) {
            for (char j = 'a'; j <= 'z'; ++j) {
                s[i] = j;
                ++f[j - 'a'];
                if (check(n - i - 1)) {
                    break;
                }
                --f[j - 'a'];
            }            
        }        
        cout<<s<<endl;
    }
}
