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 main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string x;
    cin >> x;
    if (n % k) {
      cout << -1;
      cout << "\n";
      continue;
    }
    if (k == 1) {
      cout << x;
      cout << "\n";
      continue;
    }
    vector<long long> cnt(28, 0);
    for (long long i = 0; i < x.size(); i++) cnt[x[i] - 'a']++;
    bool chk = true;
    for (long long i = 0; i < 26; i++)
      if (cnt[i] % k) chk = false;
    if (chk) {
      cout << x;
      cout << "\n";
      continue;
    }
    for (long long i = n - 1; i >= 0; i--) {
      cnt[x[i] - 'a']--;
      long long sum = 0;
      char ch1 = x[i];
      char ch2 = 'A';
      for (long long m = 0; m < 26; m++) {
        if (cnt[m] % k) {
          sum += k - cnt[m] % k;
          if (ch2 == 'A' && m > x[i] - 'a') {
            ch2 = 'a' + m;
          }
        }
      }
      if ((sum < n - i && (n - i - sum) % k == 0) ||
          (sum == n - i && ch2 > x[i])) {
        if (sum == n - i) {
          x[i] = ch2;
          cnt[ch2 - 'a']++;
          sum--;
        } else {
          x[i] = ch1 + 1;
          sum -= (k - cnt[ch1 + 1 - 'a'] % k) % k;
          cnt[ch1 + 1 - 'a']++;
          sum += (k - cnt[ch1 + 1 - 'a'] % k) % k;
        }
        if (sum > n - i - 1) continue;
        for (long long j = i + 1; j < n - sum; j++) {
          x[j] = 'a';
        }
        long long ind = n - sum;
        for (long long j = 0; j < 26; j++) {
          if (cnt[j] != 0) {
            for (long long l = 0; l < (k - cnt[j] % k) % k; l++) {
              x[ind] = 'a' + j;
              ind++;
            }
          }
        }
        cout << x;
        cout << "\n";
        break;
      }
    }
  }
  return 0;
}
