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;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, k;
    string s;
    cin >> n >> k >> s;
    if (n % k != 0) {
      cout << -1 << "\n";
      continue;
    }
    if (k == 1) {
      cout << s << "\n";
      continue;
    }
    int idx = -1;
    char ca = 'a';
    map<char, int> mm;
    int to_fill = 0;
    for (int i = 0; i < n; i++) {
      for (char c = char(s[i] + 1); c <= 'z'; c++) {
        int rr = to_fill;
        if (mm[c] % k > 0) {
          rr--;
        } else {
          rr += k - 1;
        }
        int ll = n - (i + 1) - rr;
        if (ll >= 0 && ll % k == 0) {
          idx = i;
          ca = c;
          break;
        }
      }
      if (mm[s[i]] % k > 0) {
        to_fill--;
      } else {
        to_fill += k - 1;
      }
      mm[s[i]]++;
    }
    mm.clear();
    string ans = s;
    ans[idx] = ca;
    for (int i = 0; i < idx; i++) {
      mm[ans[i]]++;
    }
    mm[ca]++;
    int i = n - 1;
    for (auto it = mm.rbegin(); it != mm.rend(); it++) {
      int len = (it->second % k == 0 ? 0 : k - it->second % k);
      for (int j = 0; j < len; j++) {
        ans[i] = it->first;
        i--;
      }
    }
    while (i > idx) {
      ans[i] = 'a';
      i--;
    }
    cout << ans << endl;
  }
  return 0;
}
