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 n, m;
string solve(string s) {
  unordered_map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    mp[s[i]]++;
  }
  int ok = 1;
  for (int i = 'a'; i <= 'z'; i++) {
    if (mp[i] % m != 0) {
      ok = 0;
      break;
    }
  }
  if (ok) return s;
  for (int i = n; i >= 1; i--) {
    int j = 'a';
    vector<int> p;
    int cnt = 0;
    mp[s[i]]--;
    for (; j <= 'z'; j++) {
      if (mp[j] % m != 0) {
        p.push_back(j);
        cnt += (m - mp[j] % m) % m;
      }
    }
    if (p.size() == 0) {
      return s;
    }
    if (n - i + 1 < cnt) continue;
    for (j = s[i] + 1; j <= 'z'; j++) {
      int r = n - i;
      cnt -= (m - mp[j] % m) % m;
      cnt += (m - (mp[j] + 1) % m) % m;
      int need = (m - (mp[j] + 1) % m) % m;
      if (r == cnt) {
        int o = 0;
        mp[j]++;
        s[i] = j;
        int yyy = 0;
        for (auto kk : p) {
          cout << kk << " ";
          if (kk == j) {
            yyy = 1;
            break;
          }
        }
        if (!yyy) p.push_back(s[i]);
        o = 0;
        cout << endl;
        for (int k = i + 1; k <= n; k++) {
          while ((m - (mp[p[o]]) % m) % m == 0) o++;
          s[k] = p[o];
          mp[p[o]]--;
        }
        return s;
      }
    }
  }
  assert(0);
  return s;
}
int main() {
  ios::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    string s;
    cin >> s;
    s = "x" + s;
    if (n % m != 0) {
      cout << -1 << endl;
      continue;
    }
    cout << solve(s).substr(1, n) << endl;
  }
  return 0;
}
