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;
int i, j, k, n, m, a[100500][30], t;
char s[100500], ans[100500];
bool chk(int x, int y) {
  int b[30] = {0}, i, j, k = 0;
  for (i = 1; i <= 26; i++) {
    b[i] = a[x - 1][i];
  }
  b[y]++;
  for (i = 1; i <= 26; i++) {
    if (b[i] % m) {
      k += m - (b[i] % m);
      b[i] = m - (b[i] % m);
    }
  }
  if (k > (n - x)) {
    return 0;
  }
  k -= (n - x);
  if (k % m) {
    return 0;
  }
  for (i = 1; i <= n; i++) {
    ans[i] = s[i];
  }
  ans[x] = 'a' - 1 + y;
  for (i = n; i > x; i--) {
    for (j = 26; j >= 1; j--) {
      if (b[j]) {
        b[j]--;
        ans[i] = 'a' + j - 1;
        goto bbb;
      }
    }
    ans[i] = 'a';
  bbb:;
  }
  cout << ans + 1 << endl;
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> t;
  while (t--) {
    cin >> n >> m >> s + 1;
    if (n % m) {
      cout << -1 << endl;
      continue;
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= 26; j++) {
        a[i][j] = a[i - 1][j];
      }
      a[i][s[i] - 'a' + 1]++;
    }
    for (i = 1; i <= 26; i++) {
      if (a[n][i] % m) {
        goto aaa;
      }
    }
    cout << s + 1 << endl;
    continue;
  aaa:
    for (i = n; i >= 1; i--) {
      for (j = s[i] - 'a' + 2; j <= 26; j++) {
        if (chk(i, j)) {
          goto ccc;
        }
      }
    }
  ccc:;
  }
}
