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 = 1e6 + 10;
int n, k, t, tot;
map<char, int> m;
string s;
string process() {
  if (tot == 0) return s;
  string ss;
  for (int i = (n - 1); i >= (0); i--) {
    char cc = s[i];
    tot = tot + (k - m[cc] + 1) % k - (k - m[cc]) % k;
    m[cc]--;
    m[cc] = m[cc] % k;
    if (m[cc] < 0) m[cc] += k;
    for (char c = s[i] + 1; c <= 'z'; c++) {
      s[i] = c;
      tot = tot + (k - m[c] - 1) % k - (k - m[c]) % k;
      m[c]++;
      m[c] = m[c] % k;
      int tot2 = n - i - 1;
      if (tot <= tot2) {
        for (int j = (0); j <= (i); j++) ss.push_back(s[j]);
        for (int j = (i + 1); j <= (n - 1 - tot2); j++) ss.push_back('a');
        for (auto p : m) {
          int l = (k - p.second) % k;
          while (l--) {
            ss.push_back(p.first);
          }
        }
        return ss;
      }
      tot = tot + (k - m[c] + 1) % k - (k - m[c]) % k;
      m[c]--;
      m[c] = m[c] % k;
      if (m[c] < 0) m[c] += k;
    }
  }
  return "-1";
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> k;
    cin >> s;
    m.clear();
    tot = 0;
    if (n % k > 0) {
      cout << "-1" << endl;
      continue;
    }
    int i = 0;
    for (auto c : s) {
      m[c]++;
      m[c] = m[c] % k;
    }
    for (auto p : m) {
      tot += (k - m[p.first]) % k;
    }
    cout << process() << endl;
  }
  return 0;
}
