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>
#pragma GCC optimize("Ofast")
using namespace std;
long long k;
bool ifk(string s) {
  vector<long long> kol(27, 0);
  for (auto t : s) kol[t - 'a']++;
  bool d = 1;
  for (long long i = 0; i < 27; i++)
    if ((kol[i] % k) != 0) {
      d = 0;
      break;
    }
  return d;
}
int main() {
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n >> k;
    string s;
    cin >> s;
    long long sum = 0;
    vector<long long> kol(27, 0);
    for (long long i = 0; i < n; i++) kol[s[i] - 'a']++;
    for (long long i = 0; i < 27; i++) sum += (k - kol[i] % k) % k;
    long long ost = 0;
    string ans;
    for (long long pr = n - 1; pr >= 0; pr--) {
      if (ost >= sum) {
        for (long long tek = (s[pr + 1] + 1 - 'a'); tek < 27; tek++) {
          long long teksum = sum;
          string t = s;
          long long j = n - 1;
          t[pr + 1] = tek + 'a';
          teksum -= (k - kol[tek] % k) % k;
          kol[tek]++;
          teksum += (k - kol[tek] % k) % k;
          for (long long h = 26; h > 0; h--)
            if (kol[h] > 0) {
              long long kkk = (k - kol[h] % k) % k;
              while (j > (pr + 1) && kkk > 0) {
                t[j] = (h + 'a');
                j--;
                kkk--;
              }
            }
          while (j > (pr + 1)) {
            t[j] = 'a';
            j--;
          }
          if (ifk(t)) {
            ans = t;
            break;
          }
          kol[tek]--;
        }
      }
      if (ans != "") break;
      sum -= (k - kol[s[pr] - 'a'] % k) % k;
      kol[s[pr] - 'a']--;
      ost++;
      sum += (k - kol[s[pr] - 'a'] % k) % k;
    }
    if ((n % k) != 0)
      cout << -1 << '\n';
    else
      cout << ans << '\n';
  }
  return 0;
}
