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;
const int N = 2010, NN = 1e6 + 10, length = 25, mod = 1e9 + 7;
int freq[26], n, k;
string a;
struct solvaia {
  int changes;
  vector<pair<char, int> > vec;
};
solvaia solve() {
  solvaia cur = {0};
  for (char c = 'a'; c <= 'z'; c++) {
    if ((k - (freq[c - 'a'] % k)) % k)
      cur.vec.push_back({c, (k - (freq[c - 'a'] % k)) % k});
    cur.changes += (k - (freq[c - 'a'] % k)) % k;
  }
  return cur;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k >> a;
    memset(freq, 0, sizeof freq);
    if (n % k) {
      cout << "-1\n";
      continue;
    }
    for (int i = 0; i < n; i++) freq[a[i] - 'a']++;
    int cur = 0, ok = 0;
    string ans = a;
    solvaia lol = solve();
    if (lol.changes == 0) {
      cout << a << '\n';
      continue;
    }
    for (int i = n - 1; i >= 0; i--) {
      freq[a[i] - 'a']--;
      if (a[i] == 'z') {
        ans.pop_back();
        cur++;
        continue;
      }
      a[i]++;
      freq[a[i] - 'a']++;
      solvaia current = solve();
      if (current.changes > cur) {
        freq[a[i] - 'a']--;
        a[i]--;
        ans.pop_back();
        cur++;
        continue;
      }
      ans.back()++;
      if (current.vec.size()) {
        sort(current.vec.begin(), current.vec.end());
        reverse(current.vec.begin(), current.vec.end());
      }
      while (current.vec.size()) {
        ans += current.vec.back().first;
        current.vec.back().second--;
        if (current.vec.back().second == 0) current.vec.pop_back();
      }
      ok = 1;
      break;
    }
    while (ans.size() < n) ans.push_back('a');
    if (ok)
      cout << ans << '\n';
    else
      cout << "-1" << '\n';
  }
}
