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 solve() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (n % k != 0) {
    cout << -1 << endl;
    return;
  }
  int a[26] = {};
  for (char ch : s) a[ch - 'a']++;
  vector<int> opts;
  for (int i = 0; i < 26; i++)
    if (a[i]) {
      opts.push_back(i);
    }
  bool is_beautiful = true;
  for (int i = 0; i < 26; i++) {
    is_beautiful &= (a[i] % k == 0);
  }
  if (is_beautiful) {
    cout << s << endl;
    return;
  }
  int L = 0, R = n;
  while (L < R - 1) {
    int M = (L + R) / 2;
    int b[26] = {}, len = 0;
    for (int i = 0; i < M; i++) b[s[i] - 'a']++;
    string suff;
    for (int i = 0; i < 26; i++)
      if (b[i] % k) {
        len += k - b[i] % k;
        suff += string(k - b[i] % k, 'a' + i);
      }
    bool ok;
    if (M + len > n) {
      ok = 0;
    } else {
      int rest = n - (M + len);
      suff += string(rest, 'z');
      reverse(suff.begin(), suff.end());
      const char *p1 = suff.c_str(), *p2 = (s.c_str() + M);
      assert(strlen(p1) == strlen(p2));
      ok = (strcmp(p1, p2) > 0) ? 1 : 0;
    }
    if (ok)
      L = M;
    else
      R = M;
  }
  cout << "L: " << L << endl;
  assert(s[L] != 'z');
  string ans;
  int b[26] = {};
  for (int i = 0; i < L; i++) {
    b[s[i] - 'a']++;
    ans += s[i];
  }
  int len = 0, next = -1;
  for (int i = 0; i < 26; i++)
    if (b[i] % k) {
      len += k - b[i] % k;
      if (next == -1 && i > (s[L] - 'a')) {
        next = i;
      }
    }
  char ch = (L + len == n) ? next + 'a' : s[L] + 1;
  b[ch - 'a']++;
  ans += ch;
  for (int i = 0; i < 26; i++)
    if (b[i] % k) {
      ans += string(k - b[i] % k, 'a' + i);
    }
  assert(ans.size() == n);
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
}
