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;
template <class T>
bool ckmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
void solve() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (n % k) {
    cout << "-1\n";
    return;
  }
  int need = 0;
  vector<int> cnt(26);
  int j = -1, left = 0;
  for (int i = 0; i < n; ++i) {
    int id = s[i] - 'a';
    need -= (k - cnt[id]) % k;
    cnt[id] = (cnt[id] + 1) % k;
    need += (k - cnt[id]) % k;
    if ((n - i - 1 - need) % k == 0 && need <= n - i - 1) {
      if (n == i + 1 && need == 0) j = i, left = 0;
      int mx = -1, lf = (n - i - 1 - need) / k;
      for (int q = 0; q < 26; ++q) {
        if (cnt[q]) mx = q;
      }
      if (s[i + 1] == 'z') continue;
      if (mx + 'a' > s[i + 1] || need < n - i - 1) j = i, left = lf;
    }
  }
  if (j == -1) left = n / k;
  need = 0;
  fill(cnt.begin(), cnt.end(), 0);
  for (int i = 0; i <= j; ++i) {
    int id = s[i] - 'a';
    need -= (k - cnt[id]) % k;
    cnt[id] = (cnt[id] + 1) % k;
    need += (k - cnt[id]) % k;
  }
  int flag = 1;
  vector<char> use;
  for (int i = 0; i < 26; ++i) {
    for (int q = 0; q < (k - cnt[i]) % k; ++q) {
      if (j + 1 < n && (s[j + 1] - 'a') + 1 == q) flag = 0;
      use.push_back('a' + i);
    }
  }
  if (left) {
    int r = flag;
    for (int i = 0; i < r; ++i) {
      for (int q = 0; q < k; ++q) use.push_back(1 + s[j + 1]);
      flag = 1;
    }
    for (int i = r; i < left; ++i) {
      for (int q = 0; q < k; ++q) use.push_back('a');
    }
  }
  sort(use.begin(), use.end());
  if (int(use.size())) {
    int w = 0;
    for (int i = 0; i < int(use.size()); ++i) {
      if (j + 1 < n && use[i] > s[j + 1]) {
        w = i;
        break;
      }
    }
    swap(use[0], use[w]);
    if (j + 1 < n) assert(use[0] > s[j + 1]);
  }
  if (use.size()) sort(use.begin() + 1, use.end());
  for (int i = 0; i <= j; ++i) cout << s[i];
  for (int q = 0; q < int(use.size()); ++q) cout << use[q];
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
