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;
using ll = long long;
const ll inf = 1e18;
int n, m, k;
string s;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    cin >> s;
    if (k == 1) {
      cout << s << "\n";
      continue;
    }
    vector<vector<int> > pref(n, vector<int>(26)), suf(n, vector<int>(26));
    pref[0][s[0] - 'a'] = 1;
    for (int i = 1; i < n; i++) {
      pref[i][s[i] - 'a'] = 1;
      for (int j = 0; j < 26; j++) {
        pref[i][j] += pref[i - 1][j];
      }
    }
    suf[n - 1][s[n - 1] - 'a'] = 1;
    for (int i = n - 2; i >= 0; i--) {
      suf[i][s[i] - 'a'] = 1;
      for (int j = 0; j < 26; j++) {
        suf[i][j] += suf[i + 1][j];
      }
    }
    bool f = 0;
    vector<int> lind(26, -1);
    for (int i = n - 1; i >= 0; i--) {
      pref[i][s[i] - 'a']--;
      lind[s[i] - 'a'] = i;
      int tot = n - i;
      vector<pair<int, int> > v, inneed;
      vector<int> pos;
      for (int j = 0; j < 26; j++) {
        if (pref[i][j] % k) {
          tot -= k - (pref[i][j] % k);
          inneed.push_back({j, k - (pref[i][j] % k)});
        }
        if (pref[i][j]) pos.push_back(j);
        if (lind[j] != -1) {
          v.push_back({lind[j], j});
        }
      }
      if (tot < 0) continue;
      sort(v.begin(), v.end());
      if (tot == 0) {
        bool ok = 0;
        for (auto& x : inneed) {
          if (x.first > s[i] - 'a') {
            x.second--;
            s[i] = x.first + 'a';
            ok = 1;
            break;
          }
        }
        if (ok) {
          f = 1;
          int ind = 0;
          for (int j = i + 1; j < n; j++) {
            if (inneed[ind].second == 0) ind++;
            s[j] = inneed[ind].first + 'a';
            inneed[ind].second--;
          }
          break;
        }
      } else {
        if (tot % k) continue;
        if (s[i] == 'z') continue;
        int x = (s[i] - 'a') + 1;
        bool ined = 0;
        for (auto& y : inneed) {
          if (y.first == x) {
            ined = 1;
            y.second--;
            break;
          }
        }
        if (!ined) {
          s[i] = x + 'a';
          inneed.push_back({x, k - 1});
          tot -= k;
        }
        f = 1;
        inneed.push_back({0, tot});
        sort(inneed.begin(), inneed.end());
        int ind = 0;
        for (int j = i + 1; j < n; j++) {
          if (inneed[ind].second == 0) ind++;
          s[j] = inneed[ind].first + 'a';
          inneed[ind].second--;
        }
        break;
      }
    }
    if (!f) {
      cout << -1 << "\n";
      continue;
    }
    cout << s << "\n";
  }
  return 0;
}
