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;
void GO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
const long long INF = 1e9 + 7;
const long long mod = (998244353);
const int maxn = (int)4e5;
const long double PI = acos(-1.0);
const long double eps = 0.000000001;
mt19937 rnd(time(0));
void solve() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (n % k) {
    cout << "-1\n";
    return;
  }
  vector<vector<int> > alp(n, vector<int>(27));
  alp[0][int(s[0] - 'a')] = 1;
  for (int i = 1; i < n; ++i) {
    alp[i] = alp[i - 1];
    alp[i][int(s[i] - 'a')]++;
  }
  bool f = 1;
  for (int i = 0; i < 27; ++i)
    if (alp[n - 1][i] % k) {
      f = 0;
      break;
    }
  if (f) {
    cout << s << '\n';
    return;
  }
  for (int i = n - 1; i >= 0; --i) {
    int ost = n - 1 - i;
    if (s[i] == 'z') continue;
    int c = int(s[i] - 'a') + 1;
    alp[i][c - 1]--;
    int now = 1;
    f = 1;
    for (int j = 0; j < 27; ++j) {
      if (alp[i][j] % k == 0) continue;
      int need = k - alp[i][j] % k;
      if (need > ost + now) {
        f = 0;
        break;
      }
      if (now && j >= c) now = 0, need--;
      if (ost < need) {
        f = 0;
        break;
      }
      ost -= need;
    }
    if ((ost + now) % k || !f) continue;
    cout << s.substr(0, i);
    string ans;
    string x;
    if (now) {
      x += char(c + 'a');
      for (int _ = 0; _ < k - 1; ++_) ans += char(c + 'a');
      for (int _ = 0; _ < ost - k + 1; ++_) ans += 'a';
    } else
      for (int _ = 0; _ < ost; ++_) ans += 'a';
    now = 1;
    for (int j = 0; j < 27; ++j) {
      if (alp[i][j] % k == 0) continue;
      int need = k - alp[i][j] % k;
      if (now && j >= c) x += char(j + 'a'), need--, now = 0;
      for (int _ = 0; _ < need; ++_) ans += char(j + 'a');
    }
    sort(ans.begin(), ans.end());
    cout << x << ans << '\n';
    return;
  }
}
signed main() {
  GO();
  int Q = 1;
  cin >> Q;
  while (Q--) {
    solve();
  }
}
