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 ll long long
#define pb push_back
#define mod 1000000007
#define inf 100000000000000000
#define ar array
#define send ios::sync_with_stdio(false);
#define help cin.tie(0);
#define setpres(x) fixed<<setprecision(x)
#define sz(x) int32_t((x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { for(int i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<"\n";}
template<typename A,typename B> ostream& operator<<(ostream &cout, map<A,B> const &v) { for(auto x:v) cout<<x.first<<": "<<x.second<<"\n";}
template<typename A> ostream& operator<<(ostream &cout, vector<ar<A,2>> const &v) { for(int i=0;i<v.size();i++) cout<<v[i][0]<<" "<<v[i][1]<<"\n";}

int32_t main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        if(n%k)
        {
            cout<<-1<<"\n";
            continue;
        }
        int cnt[26]={0};
        int pos=-1;
        int ch=-1;
        for(int i=0;i<n;i++)
        {
            for(int j=s[i]-'a'+1;j<=25;j++)
            {
                cnt[j]++;
                int mn=0;
                for(int kk=0;kk<26;kk++)
                    mn+=(cnt[kk]%k==0?0:k-(cnt[kk]%k));
                cnt[j]--;
                if(mn<=n-i-1)
                {
                    pos=i;
                    ch=j;
                    break;
                }
            }
            cnt[s[i]-'a']++;
        }
        int ok=1;
        for(int i=0;i<26;i++)
            ok&=(cnt[i]%k==0);
        if(ok)
        {
            cout<<s<<"\n";
            continue;
        }
        assert(pos!=-1);
        string ans;
        memset(cnt,0,sizeof(cnt));
        for(int i=0;i<pos;i++)
            ans+=s[i];
        ans+=string(1,char('a'+ch));
        // cout<<"ans: init: "<<ans<<"\n";
        // cout<<pos<<" "<<ch<<"\n";
        for(auto x:ans)
            cnt[x-'a']++;
        for(int i=0;i<26;i++)
        {
            int mn=(cnt[i]%k==0?0:k-(cnt[i])%k);
            for(int j=0;j<mn;j++)
                ans+=string(1,char('a'+i));
        }
        int x=sz(ans);
        for(int i=0;i<n-x;i++)
            ans+='a';
        sort(ans.begin()+pos+1,ans.end());
        cout<<ans<<"\n";
    }
}
