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>
#include<algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const double pi=3.141592653589;
long long int mod = 1000000007;
long long int mod2 = 1000000009;
const long long int inf = 1e9;
const long long int inff = 9000000000000000000;
long double eps = 1e-9;
const long long int maxn=1000000+3;
#define pry  cout<<"YES\n"
#define prn  cout<<"NO\n"
#define prm cout<<"-1\n"
#define nl cout<<"\n"
#define loop(i,a,b) for(ll i=a;i<b;i+=1)
#define rloop(i,a,b) for(ll i=a;i>=b;i-=1)
#define ll long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sd second
#define pii pair<int,int>
#define pll pair<long long int, long long int>
#define vit(a) vector<ll>:: iterator a
#define sit(a) set<ll>:: iterator a
#define msit(a) multiset<ll>:: iterator a
#define vitp(a) vector<pll>:: iterator a
#define sitp(a) set<pll>:: iterator a
#define msitp(a) multiset<pll>:: iterator a
#define mysort(a) sort(a.begin(),a.end())
#define myreverse(a) reverse(a.begin(),a.end())
#define mylb(a,val) lower_bound(a.begin(),a.end(),val)
#define myub(a,val) upper_bound(a.begin(),a.end(),val)
#define mem(a,vall) memset(a, vall, sizeof(a))
#define ordered_set tree< pll, null_type,less< pll >, rb_tree_tag,tree_order_statistics_node_update>

ld power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}

/*ll fac[maxn];
ll invfac[maxn];
ll ncr(ll n, ll r, ll p)
{
    if(r>n) return 0;

    if (r==0) return 1;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}*/

/*ll log(ll a,ll b)
{
    if(a==1)
        return b;
    ll ans = 0;
    while(b)
    {
        ans++;
        b/=a;
    }
    return ans-1;
}*/

int is_prime[2001];
void sieve()
{
    for(ll i=2; i<=2000; i++)
    {
        if(is_prime[i])
        {
            for(ll j=i*i; j<=2000; j+=i)
            {
                if(is_prime[j]==1)
                {
                    is_prime[j]=0;
                    //smallestfactor[j]=i;
                }
            }
        }
    }
}

/*ll lp[200000+1]; // Caution :  set lp first as : lp[i] = i;
vector<ll> pr;
void sieve2()
{
    loop(i,2,1)
    {
        if(lp[i]==i){pr.pb(i);}

        for(ll j=0; j<(int)pr.size() && i*pr[j]<=200000-1 && pr[j]<=lp[i]; j++)
        {
            lp[i*pr[j]]=pr[j];
        }
    }
}*/





int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int test=1;
    //freopen("dull.in", "r", stdin);       // file open for input
    //freopen("output.txt", "w", stdout);   // file open for output
    cin>>test;                              // comment this when number of testcases = 1

    while(test--)
    {

        ll n,k,sol=0;
        cin>>n>>k;
        string s;
        cin>>s;
        if(n%k!=0){prm; continue;}
        ll freq[26];
        mem(freq,0);
        loop(i,0,n){freq[s[i]-'a']++;}

        ll x=1,y;
        pll g;
        set<pll> sett;
        sitp(it);
        loop(i,0,26){if(freq[i]%k != 0){x=0; break;}}
        if(x){cout<<s; nl; continue;}

        rloop(i,n-1,1)
        {
            freq[s[i]-'a']--;
            x=0;
            sett.clear();
            loop(j,0,26)
            {
                if(freq[j]%k==0) continue;

                x+=k-(freq[j]%k);
                sett.insert({j,k-(freq[j]%k)});
            }
            if(x>n-i || s[i]=='z'){continue;}

            it=sett.lower_bound({s[i]-'a',inff});
            if(x+k<=n-i || (it!=sett.end() && x<=n-i))
            {
                if(it==sett.end()){y=s[i]-'a'+1; sett.insert({y,k-1});}
                else{g=*it; y=g.ft; sett.erase(it); sett.insert({g.ft,g.sd-1});}
                string ans;
                x=n;
                loop(j,0,i){ans.pb(s[j]); x--;}
                ans.pb((char)(y+'a'));
                x--;
                it=sett.begin();
                while(it!=sett.end())
                {
                    g=*it;
                    x-=g.sd;
                    it++;
                }
                loop(j,0,x){ans.pb('a');}
                it=sett.begin();
                while(it!=sett.end())
                {
                    g=*it;
                    loop(j,0,g.sd){ans.pb((char)('a'+g.ft));}
                    it++;
                }
                cout<<ans;
                nl;
                sol=1;
                break;
            }
        }

        if(sol==0)
        {
            if(s[0]=='z'){prm; continue;}

            y=s[0]-'a'+1;
            cout<<(char)(y+'a');
            loop(i,0,n-k){cout<<'a';}
            loop(i,0,k-1){cout<<(char)(y+'a');}
            nl;
        }

    }

   return 0;
}
