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;
ostream& operator<<(ostream& outStream, const vector<int>& v) {
  for (auto u : v) outStream << u << " ";
  return outStream << '\n';
}
istream& operator>>(istream& inStream, vector<int>& v) {
  for (auto& u : v) inStream >> u;
  return inStream;
}
void solveC() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (n % k != 0) {
    cout << -1 << '\n';
    return;
  }
  vector<vector<int> > cnt(n + 1, vector<int>(26, 0));
  for (int i = 0; i < n; ++i) {
    cnt[i + 1] = cnt[i];
    cnt[i + 1][s[i] - 'a']++;
    cnt[i + 1][s[i] - 'a'] %= k;
  }
  for (int i = n; i >= 0; --i) {
    int left = n - i;
    int mx = -1;
    for (int j = 0; j < 26; ++j) {
      left -= (k - cnt[i][j]) % k;
      if (mx == -1 && cnt[i][j] && (i == n || j > s[i] - 'a')) mx = j;
    }
    if (i == n) mx = 0;
    if (left >= 0 && left % k == 0 && (left > 0 || mx != -1)) {
      for (int c = 0; c < i; ++c) {
        cout << s[c];
      }
      if (i != n) {
        if (mx != -1 && left == 0) {
          cout << (char)('a' + mx);
          cnt[i][mx]++;
          cnt[i][mx] %= k;
        } else {
          cout << (char)(s[i] + 1);
          cnt[i][s[i] - 'a' + 1]++;
          left -= k;
        }
        for (int c = 0; c < left; ++c) {
          cout << 'a';
        }
        for (int c = 0; c < 26; ++c) {
          while (cnt[i][c] < k && cnt[i][c]) {
            cout << (char)('a' + c);
            cnt[i][c]++;
          }
        }
      }
      cout << '\n';
      return;
    }
  }
}
void solveD() {}
signed main() {
  int t;
  cin >> t;
  while (t--) solveC();
  return 0;
}
