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 <bits/stdc++.h>
#include <map>
#include <vector>
#include <set>
#include <chrono>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>

#define ffor(i, a, b) for(int i = a; i<b; i++)

using namespace std;

typedef long long int ll;


int binarySearch(vector<int> &arr, int left, int right, ll x, bool is_left=false) {
    if(!is_left) {
        while (left < right) {
            int mid = (left + right) / 2;
            if (x < arr[mid]) right = mid;
            else left = mid + 1;
        }
        return left;
    }
    else{
        while (left < right) {
            int mid = (left + right) / 2;
            if (x <= arr[mid]) right = mid;
            else left = mid + 1;
        }
        return left;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int modInverse(int a, int m)
{
    a = a%m;
    for (int x=1; x<m; x++)
        if ((a*x) % m == 1)
            return x;
}


string reverseStr(string str)
{
    string result = str;
    int n = str.length();
    for (int i = 0; i < n / 2; i++)
        swap(result[i], result[n - i - 1]);

    return result;
}

int parent[11];
int depth[11];

void make_set (int v) {
    parent[v] = v;
    depth[v] = 0;
}

int find_set (int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set (parent[v]);
}

void union_sets (int a, int b) {
    a = find_set (a);
    b = find_set (b);
    if (a != b) {
        if (depth[a] < depth[b])
            swap (a, b);
        parent[b] = a;
        if (depth[a] == depth[b])
            ++depth[a];
    }
}


int tree[4*2*10];

void build (vector<ll> a, int v, int left, int right) {
    if (left == right)
        tree[v] = a[left];
    else {
        int tm = (left + right) / 2;
        build (a, v*2, left, tm);
        build (a, v*2+1, tm+1, right);
        tree[v] = min(tree[v*2], tree[v*2+1]);
    }
}

int get_min (int v, int left, int right, int l, int r) {
    if (l > r)
        return 0;
    if (l == left && r == right){
        return tree[v];
    }
    int tm = (left + right) / 2;
    return min(get_min(v * 2, left, tm, l, min(r, tm))
            , get_min(v * 2 + 1, tm + 1, right, max(l, tm + 1), r));

}

void update (int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && tr == r)
        tree[v] += add;
    else {
        int tm = (tl + tr) / 2;
        update (v*2, tl, tm, l, min(r,tm), add);
        update (v*2+1, tm+1, tr, max(l,tm+1), r, add);
    }
}


int binpow (int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1)
            res *= a;
        a *= a;
        n >>= 1;
    }
    return res;
}

void reverse(int arr[], int n){
    ffor(i, 0, n/2) swap(arr[i], arr[n-1-i]);
}

vector<int> cifar(ll n){
    vector<int> ans;
    while(n){
        ans.push_back(n%10);
        n = n/10;
    }

    ffor(i, 0, ans.size()/2) swap(ans[i], ans[ans.size()-1-i]);

    return ans;
}


long long mulmod(long long a,
                 long long b,
                 long long mod)
{
    long long res = 0; // Initialize result

    // Update a if it is more than
    // or equal to mod
    a %= mod;

    while (b)
    {
        // If b is odd, add a with result
        if (b & 1)
            res = (res + a) % mod;

        // Here we assume that doing 2*a
        // doesn't cause overflow
        a = (2 * a) % mod;

        b >>= 1; // b = b / 2
    }

    return res;
}


vector<int> z_function (string s) {
    int n = (int) s.length();
    vector<int> z (n);
    for (int i=1, l=0, r=0; i<n; ++i) {
        if (i <= r)
            z[i] = min (r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if (i+z[i]-1 > r)
            l = i,  r = i+z[i]-1;
    }
    return z;
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int t;
  int n;
  int k;

  cin>>t;
  string s;

  int ansPos;
  int ansTarget;
  int count;
  int ind;
  int p;
  string ans;

  ffor(_, 0, t){
    cin>>n>>k;
    cin>>s;
    int dl[26] = {0};
    ansPos = -1;
    ansTarget = -1;

    ffor(i, 0, n){
      ind = s[i] - 'a';
        
      ffor(w, ind+1, 26){
        dl[w]++;

        count = 0;

        ffor(j, 0, 26){
          count += (k - (dl[j] % k)) % k;
        }

        p = n - i - 1 - count;

        //cout<<"IP"<<i<<' '<<p<<endl;

        if(p>=0 && p%k==0) {
          ansPos = i;
          ansTarget = w;
          //cout<<ansPos<<' '<<w<<endl;
        }

        dl[w]--;
        if(ansPos==i) break;
      }

      dl[ind]++;
    }

    bool flag = true;

    ffor(i, 0, 26){
      if(dl[i]%k!=0){
        flag = false;
        break;
      }
    }

    if(flag) cout<<s<<endl;
    else{
      //cout<<"ANS:"<<ansPos<<endl;
      //cout<<"ANSTARGET:"<<char(ansTarget)<<endl;
      if(ansPos==-1) cout<<-1<<endl;
      else{
        int cl[26] = {0};

        ans = "";

        ffor(i, 0, ansPos){
          ans += s[i];
          cl[s[i]-'a']++;
        }

        cl[ansTarget]++;
        //cout<<char(ansTarget + 'a')<<endl;
        ans += char(ansTarget + 'a');

        count = 0;

        ffor(j, 0, 26){
          count += (k - (cl[j] % k)) % k;
        }

        //cout<<n - 1 - count - ansPos<<endl;
        ffor(i, 0, n - 1 - count - ansPos) ans += 'a';

        ffor(i, 0, 26){
          ffor(j, 0, (k - (cl[i] % k)) % k) ans += char('a' + i);
        }

        cout<<ans<<endl;
      }
    }
  }

  return 0;
}