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 pre[30][100050];
int n, k;
string s;
string ss;
bool judge(int x) {
  int ori;
  ss = s;
  while (s[x] == 'z' && x <= n) x++;
  if (x == n + 1) return 0;
  int cnt = 0;
  for (int i = 0; i < 26; i++) {
    cnt += (k - pre[i][x - 1] % k) % k;
  }
  if (cnt > n - x + 1) {
    return 0;
  } else if (cnt == n - x + 1) {
    int ne = s[x];
    for (int i = s[x] - 'a' + 1; i < 26; i++) {
      if (pre[i][x - 1] % k != 0) {
        ne = 'a' + i;
        break;
      }
    }
    if (ne == s[x]) {
      if (pre[ne - 'a'][x - 1] == 0) return 0;
    }
    ori = ss[x];
    ss[x] = ne;
  } else {
    ori = ss[x];
    ss[x]++;
  }
  pre[ss[x] - 'a'][x]++;
  pre[ori - 'a'][x]--;
  int pos = n;
  for (int i = 25; i >= 0; i--) {
    for (int j = 1; j <= (k - pre[i][x] % k) % k; j++) {
      ss[pos--] = 'a' + i;
    }
  }
  for (; pos > x; pos--) {
    ss[pos] = 'a';
  }
  pre[ss[x] - 'a'][x]--;
  pre[ori - 'a'][x]++;
  return 1;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    scanf("%d%d", &n, &k);
    cin >> s;
    s = " " + s;
    if (n / k * k != n) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < 26; j++) {
        pre[j][i] = pre[j][i - 1];
      }
      pre[s[i] - 'a'][i]++;
    }
    int flag = 0;
    for (int i = 0; i < 26; i++) {
      if (pre[i][n] % k != 0) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      for (int i = 1; i <= n; i++) {
        putchar(s[i]);
      }
      cout << endl;
      continue;
    }
    int l = 1, r = n;
    while (l <= r) {
      int m = (l + r) >> 1;
      if (judge(m))
        l = m + 1;
      else
        r = m - 1;
    }
    if (!judge(l - 1)) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 1; i <= n; i++) {
      putchar(ss[i]);
    }
    cout << endl;
  }
}
