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;
char str[10010];
struct CH {
  int num;
  int cnt;
  int need;
} ch[30];
bool cmp1(CH a, CH b) { return a.num < b.num; }
bool cmp2(CH a, CH b) {
  if (a.need == 0 && b.need == 0) return a.num > b.num;
  if (a.need == 0 || b.need == 0) return a.need > b.need;
  return a.num > b.num;
}
int calcr(int now, int n, int k) {
  int need = 0;
  for (int i = 0; i < 26; i++) {
    need += ch[i].need;
  }
  if (need > n - now) return 0;
  return n - now - need;
}
bool check(int now, int n, int k) {
  sort(ch, ch + 26, cmp2);
  int need = 0;
  for (int i = 0; i < 26; i++) {
    need += ch[i].need;
  }
  if (need > n - now) return 0;
  int restneed = 0, tryn = 0, cntn = 0;
  restneed = n - now - need;
  for (int i = now; i < n; i++) {
    if (restneed) {
      if (str[i] == 'z') {
        restneed--;
      } else
        return 1;
    } else {
      if (ch[tryn].num > str[i] - 'a') return 1;
      if (ch[tryn].num < str[i] - 'a') return 0;
      cntn++;
      if (cntn == ch[tryn].need) {
        cntn = 0;
        tryn++;
      }
    }
  }
  return 1;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    memset(ch, 0, sizeof(ch));
    for (int i = 0; i <= 'z' - 'a'; i++) {
      ch[i].num = i;
    }
    int k, n;
    scanf("%d%d", &n, &k);
    scanf("%s", &str);
    if (n % k != 0) {
      printf("-1\n");
      continue;
    }
    for (int i = 0; i < n; i++) {
      ch[str[i] - 'a'].cnt++;
      if (ch[str[i] - 'a'].cnt % k == 0) {
        ch[str[i] - 'a'].need = 0;
      } else {
        ch[str[i] - 'a'].need = k - ch[str[i] - 'a'].cnt % k;
      }
    }
    int flag = 0;
    for (int i = n; i > 0; i--) {
      if (check(i, n, k)) {
        flag = i;
        break;
      }
      sort(ch, ch + 26, cmp1);
      ch[str[i - 1] - 'a'].cnt--;
      if (ch[str[i - 1] - 'a'].cnt % k == 0) {
        ch[str[i - 1] - 'a'].need = 0;
      } else {
        ch[str[i - 1] - 'a'].need = k - ch[str[i - 1] - 'a'].cnt % k;
      }
    }
    for (int i = 0; i < flag; i++) {
      printf("%c", str[i]);
    }
    if (flag == n) continue;
    sort(ch, ch + 26, cmp1);
    int restneed = calcr(flag, n, k);
    if (restneed && ch[str[flag] - 'a' + 1].need == 0) {
      ch[str[flag] - 'a' + 1].need += k - 1;
      printf("%c", str[flag] + 1);
      restneed -= k;
    } else {
      for (int i = str[flag] - 'a' + 1; i < 26; i++) {
        if (ch[i].need != 0) {
          printf("%c", i + 'a');
          ch[i].need--;
          break;
        }
      }
    }
    ch[0].need += restneed;
    for (int i = 0; i < 26; i++) {
      while (ch[i].need) {
        printf("%c", i + 'a');
        ch[i].need--;
      }
    }
    printf("\n");
  }
  return 0;
}
