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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
// typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
/*---------------------------------------------------------------------------------------------------*/ 
int cnt[26];
int n,k;
string s;
bool ok;
void simulate(int cur,int reqd,int pos)
{
    fp(i,cur,25)
    {
        int extra=reqd;
        extra-=((k-(cnt[i]%k))%k);
        cnt[i]++;
        extra+=((k-(cnt[i]%k))%k);
        if(extra<=(n-1-pos))
        {
            string suf;
            f(j,26)
            {
                int add=((k-(cnt[j]%k))%k);
                extra-=add;
                while(add)
                {
                    cnt[j]--;
                    add--;
                    suf.pb(j+'a');
                }
            }
            while(sz(suf)<(n-1-pos))
                suf.pb('a');
            sort(all(suf));
            f(j,pos)
                cout << s[j];
            cout << char('a'+i) ;
            cout << suf << '\n';
            ok=true;
            return;
        }
        else
         cnt[i]--;
    }
}

void solve()
{   
    cin >> n >> k;
    ok=false;
    cin >> s;
    mems(cnt);
    f(i,n)
     cnt[s[i]-'a']++;
    int reqd=0;
    f(i,26)
     {
          reqd+=((k-(cnt[i]%k))%k);
     }
     if(reqd==0)
        cout << s << '\n';
     else if((n%k))
        cout << "-1\n";
     else
     {
         fr(i,n-1,0)
         {
            reqd-=((k-(cnt[s[i]-'a']%k))%k);
            cnt[s[i]-'a']--;
            reqd+=((k-(cnt[s[i]-'a']%k))%k);
            simulate(s[i]-'a'+1,reqd,i);
            if(ok)
                return;
         }
     }
}

signed main()
{
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt","r",stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  FAST
  int T=1;
  cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}
