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>
using namespace std;
#define ll long long
/// uffff this question
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t_c = 1;
  cin >> t_c;

  for (ll t = 1; t <= t_c; t++)
  {
    ll n, k;
    cin >> n >> k;

    string str;
    cin >> str;
    vector<vector<ll>> mat(n + 1, vector<ll>(26, 0));
    ll min_index = 0;

    for (ll i = 0; i < n; i++)
    {
      for (ll j = 0; j < 26; j++)
      {
        mat[i + 1][j] = mat[i][j];
      }

      // min_index = min(min_index, (ll)(str[i] - 'a'));
      mat[i + 1][str[i] - 'a'] += 1;
    }

    if (n % k)
    {
      // no solution
      cout << "-1\n";
    }

    else
    {
      // there is a solution possible
      // check if given string satisfies

      bool found = false;
      ll rem_count = 0;

      for (ll i = 0; i < 26; i++)
      {
        rem_count += (mat[n][i] % k);
      }

      if (rem_count == 0)
      {
        found = true;
        cout << str << endl;
      }

      if (!found)
      {
        ll done = false;

        // let i be the location where we introduced a bigger chracter in solution string
        for (ll i = n - 1; i >= 0; i--)
        {

          if (done)
          {
            break;
          }

          for (ll j = (str[i] - 'a') + 1; j < 26; j++)
          {
            // if (mat[n][j] == 0)
            //   continue;

            // lets try to get a solution

            ll rem_places = (n - i) - 1;
            ll rem_count = 0;
            ll x = 0; // no. of times min char will be repeated for padding

            /// uffff what a noob
            for (ll z = 0; z < 26; z++)
            {
              ll cnt = mat[i + 1][z];
              if (z == j)
              {
                cnt += 1;
              }
              else if (z == (str[i] - 'a'))
              {
                cnt -= 1;
              }
              if (cnt % k)
              {
                rem_count += (k - (cnt % k));
              }
            }

            if (rem_places >= rem_count)
            {
              if (((rem_places - rem_count) % k) == 0)
              {
                done = true;
                x = rem_places - rem_count;
              }
            }

            if (done)
            {
              // vector<char> vec;
              string ans = str.substr(0, i + 1);
              ans[i] = 'a' + j;
              cout << ans;
              for (ll z = 0; z < 26; z++)
              {
                ll times = mat[i + 1][z];
                ll repeat_count = 0;

                if (z == (str[i] - 'a'))
                {
                  times -= 1;
                }
                else if (z == j)
                {
                  times += 1;
                }

                if (times % k)
                {
                  repeat_count = k - (times % k);
                }

                if (z == min_index)
                {
                  repeat_count += x;
                }

                for (ll val = 0; val < repeat_count; val++)
                {
                  cout << (char)(z + 'a');
                  // vec.push_back(z + 'a');
                  // ans.push_back(z + 'a');
                }
              }

              cout << endl;
              break;
            }
          }
        }
      }
    }
  }
  return 0;
}