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 VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using PII = pair<int, int>;
const int SZ = 26;
int N, K;
string s;
VI cnt;
void ReadData();
void Solve();
int main() {
  int T;
  cin >> T;
  while (T--) {
    ReadData();
    Solve();
  }
  return 0;
}
void ReadData() {
  cin >> N >> K;
  cin >> s;
}
void Solve() {
  if (N % K != 0) {
    cout << "-1" << '\n';
    return;
  }
  string res;
  res.resize(N);
  cnt = VI(SZ);
  for (int i = 0; i < N; ++i) ++cnt[s[i] - 'a'];
  for (int i = 0; i < SZ; ++i) {
    cnt[i] = K - cnt[i] % K;
    if (cnt[i] == K) cnt[i] = 0;
  }
  int t = 0;
  for (int i = 0; i < SZ; ++i) t += cnt[i];
  if (t == 0) {
    cout << s << '\n';
    return;
  }
  for (int i = N - 1; i >= 0; --i) {
    t -= cnt[s[i] - 'a'];
    ++cnt[s[i] - 'a'];
    if (cnt[s[i] - 'a'] >= K) cnt[s[i] - 'a'] -= K;
    t += cnt[s[i] - 'a'];
    VI c = cnt;
    if (t <= N - i) {
      bool ok{false};
      for (char ch = s[i] + 1; ch < 'a' + SZ; ++ch)
        if (c[ch - 'a']) {
          --c[ch - 'a'];
          res[i] = ch;
          ok = true;
          break;
        }
      if (!ok) {
        if (s[i] == 'z') continue;
        int ch = s[i] + 1 - 'a';
        res[i] = ch + 'a';
        int tc = t;
        tc -= c[ch];
        --c[ch];
        if (c[ch] == -1) c[ch] = K - 1;
        tc += c[ch];
        if (tc > N - i) continue;
      }
      for (int j = 0; j < i; ++j) res[j] = s[j];
      int idx = SZ - 1;
      for (int p = N - 1; p > i; --p) {
        while (idx > -1 && c[idx] == 0) --idx;
        if (idx == -1)
          res[p] = 'a';
        else {
          res[p] = 'a' + idx, --c[idx];
        }
      }
      cout << res << '\n';
      return;
    }
  }
}
