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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long mx = 200009;
void yes() { cout << "Yes" << '\n'; }
void no() { cout << "No" << '\n'; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string str;
    cin >> str;
    int cnt[26] = {0};
    for (int i = 0; i < n; i++) cnt[str[i] - 'a']++;
    if (n % k) {
      cout << -1 << '\n';
      continue;
    }
    bool ck = 0;
    for (int i = 0; i < 26; i++) {
      if (cnt[i] % k) ck = 1;
    }
    if (ck == 0) {
      cout << str << '\n';
      continue;
    }
    for (int i = n - 1; i >= 0; i--) {
      cnt[str[i] - 'a']--;
      bool ck = 0;
      for (int j = str[i] - 'a' + 1; j < 26; j++) {
        cnt[j]++;
        int rem = n - i - 1;
        int lagbe = 0;
        for (int ii = 0; ii < 26; ii++) lagbe += (k - cnt[ii] % k) % k;
        if (rem >= lagbe and rem % k == lagbe % k) {
          str[i] = char(j + 'a');
          string newstr;
          int mini = 26;
          for (int ii = 0; ii < 26; ii++) {
            int need = (k - cnt[ii] % k) % k;
            if (need) mini = min(mini, need);
            newstr += string(need, char(ii + 'a'));
          }
          while ((long long)newstr.size() < rem) newstr += char(mini + 'a');
          sort(newstr.begin(), newstr.end());
          int suru = i + 1;
          for (auto x : newstr) str[suru++] = x;
          cout << str << '\n';
          ck = 1;
          break;
        }
        cnt[j]--;
      }
      if (ck) break;
    }
  }
}
