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>
const long long INF = LLONG_MAX / 2;
const long long N = 2e5 + 1;
using namespace std;
string s;
long long n, k;
long long co[100005][26];
long long check(long long x) {
  long long ss = 0;
  for (long long i = (long long)(s[x] - 'a') + 1; i < 26; i++) {
    long long c[26] = {0}, req = 0;
    c[i]++;
    for (long long j = 0; j < 26; j++) {
      if (j == s[x] - 'a')
        c[j] += co[x][j] - 1;
      else
        c[j] += co[x][j];
    }
    for (long long i = 0; i < 26; i++) {
      if (c[i] % k == 0) continue;
      req += ((k - (c[i] % k)) % k);
    }
    if (x + 1 + req > n) {
      ss = 0;
      continue;
    }
    if (x + req + 1 == n) return i;
    if (x + req + 1 < n) {
      if ((n - req - x - 1) % k != 0) {
        ss = 0;
        continue;
      }
      return i;
    }
  }
  if (s[x] == 'z') return x;
  return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  std::cin >> t;
  while (t--) {
    cin >> n >> k;
    cin >> s;
    if (n % k != 0) {
      cout << "-1\n";
      continue;
    }
    long long c[26] = {0};
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < 26; j++) co[i][j] = 0;
    }
    for (long long i = 0; i < n; i++) {
      c[s[i] - 'a']++;
      co[i][s[i] - 'a']++;
      for (long long j = 0; j < 26; j++) {
        if (i != 0) co[i][j] += co[i - 1][j];
      }
    }
    long long j = 0;
    for (long long i = 0; i < 26; i++) {
      if (c[i] % k != 0) {
        j = 1;
        break;
      }
    }
    if (j == 0) {
      cout << s << "\n";
      continue;
    }
    long long l = 0, r = n - 1;
    long long cc = -1;
    while (l <= r) {
      long long mid = (l + r) / 2;
      if (check(mid) > 0) {
        cc = check(mid);
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    for (long long i = 0; i < n; i++) {
      if (i < l - 1)
        cout << s[i];
      else {
        if (i == l - 1) {
          string t = "";
          char ans = 'a' + cc;
          t += ans;
          long long c[26] = {0}, req[26] = {0}, reqq = 0;
          c[cc]++;
          long long x = l - 1;
          for (long long j = 0; j < 26; j++) {
            if (j == s[x] - 'a')
              c[j] += co[x][j] - 1;
            else
              c[j] += co[x][j];
          }
          for (long long i = 0; i < 26; i++) {
            req[i] = ((k - (c[i] % k)) % k);
            reqq += req[i];
          }
          cout << ans;
          if (reqq + x + 1 == n) {
            for (long long i = 0; i < 26; i++) {
              for (long long j = 0; j < req[i]; j++) {
                cout << (char)('a' + i);
              }
            }
          } else {
            for (long long i = 0; i < (n - reqq - x - 1); i++) cout << "a";
            for (long long i = 0; i < 26; i++) {
              for (long long j = 0; j < c[i]; j++) {
                cout << (char)('a' + i);
              }
            }
          }
        }
        break;
      }
    }
    cout << "\n";
  }
}
