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;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 3e5 + 7;
int t, n, k;
char s[maxn];
int cnt[50];
int main() {
  scanf("%d", &t);
  for (int tt = 0; tt < t; tt++) {
    scanf("%d%d", &n, &k);
    scanf("%s", s + 1);
    if (n % k != 0) {
      printf("-1\n");
      continue;
    }
    for (int i = 0; i < 30; i++) cnt[i] = 0;
    for (int i = 1; i <= n; i++) cnt[s[i] - 'a']++;
    int flag = 1;
    for (int i = 0; i < 30; i++)
      if (cnt[i] % k != 0) flag = 0;
    if (flag)
      printf("%s\n", s + 1);
    else {
      int index = -1;
      int free = 0;
      int pos = 0;
      for (int i = n; i > 0; i--) {
        cnt[s[i] - 'a']--;
        int tem = free;
        flag = 1;
        for (int j = 0; j <= s[i] - 'a'; j++) {
          if (cnt[j] % k != 0) tem = tem - (k - (cnt[j] % k));
          if (tem < 0) {
            flag = 0;
            break;
          }
        }
        tem++;
        for (int j = s[i] - 'a' + 1; j < 26; j++) {
          if (cnt[j] % k != 0) {
            tem = tem - (k - (cnt[j] % k));
          }
          if (tem < 0) {
            flag = 0;
            break;
          }
        }
        if ((tem % k) != 0) flag = 0;
        if (flag) {
          index = i;
          break;
        } else
          free++;
      }
      for (int i = s[index] - 'a' + 1; i < 26; i++) {
        cnt[i]++;
        int res = 0;
        for (int j = 0; j < 26; j++) {
          res += cnt[j];
          if (cnt[j] % k) res += (k - (cnt[j] % k));
        }
        if (res <= n) {
          pos = i;
          break;
        }
        cnt[i]--;
      }
      s[index] = pos + 'a';
      int j = 29;
      for (int i = n; i >= index + 1; i--) {
        while (cnt[j] % k == 0 && j > 0) j--;
        s[i] = j + 'a';
        cnt[j]++;
      }
      printf("%s\n", s + 1);
    }
  }
  return 0;
}
