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;
bool poss(const string& s, int i, int n, map<char, int>& C) {
  for (; i < n; i++) {
    auto it = C.rbegin();
    if (it->first > s[i]) return true;
    if (it->first < s[i]) return false;
    it->second--;
    if (it->second == 0) C.erase(it->first);
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int k, n;
    cin >> n >> k;
    string s;
    cin >> s;
    if (n % k != 0) {
      cout << "-1\n";
      continue;
    }
    vector<int> nz(n, 0);
    for (int i = n - 1; i >= 0; i--) {
      if (i != n - 1 && s[i + 1] == 'z') nz[i] = nz[i + 1] + 1;
    }
    int r = n / k;
    map<char, int> C;
    vector<char> ans;
    bool gr = false;
    for (int i = 0; i < n; i++) {
      if (r == 0) {
        auto it = gr ? C.begin() : C.lower_bound(s[i]);
        if (it->first > s[i]) gr = true;
        ans.push_back(it->first);
        it->second--;
        if (it->second == 0) C.erase(it);
      } else {
        char next = gr ? 'a' : s[i];
        if (C.count(next)) {
          ans.push_back(next);
          C[next]--;
          if (C[next] == 0) C.erase(next);
        } else {
          if (!gr) {
            if (r == 1) {
              map<char, int> D = C;
              if (k != 1) D[next] = k - 1;
              if (!poss(s, i + 1, n, D)) {
                next++;
                gr = true;
              }
            } else {
              int zc = (r - 1) * k;
              if (C.count('z')) zc += C['z'];
              if (nz[i] >= zc) {
                next++;
                gr = true;
              }
            }
          }
          ans.push_back(next);
          if (k != 1) C[next] = k - 1;
          r--;
        }
      }
    }
    for (char c : ans) cout << c;
    cout << "\n";
  }
  return 0;
}
