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 yes(vector<long long int> &x, long long int k) {
  for (long long int i = 0; i < x.size(); i++) {
    if (x[i] % k) {
      return false;
    }
  }
  return true;
}
long long int sum(vector<long long int> &x, long long int k) {
  long long int s = 0;
  for (long long int i = 0; i < x.size(); i++) {
    s += (k - x[i] % k) % k;
  }
  return s;
}
int main() {
  int test;
  cin >> test;
  while (test--) {
    long long int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<long long int> x(26, 0);
    for (long long int i = 0; i < s.length(); i++) {
      x[s[i] - 'a']++;
    }
    if (n % k != 0) {
      cout << -1 << endl;
      continue;
    }
    if (yes(x, k)) {
      cout << s << endl;
      continue;
    }
    int flag = 0;
    for (long long int i = n - 1; i >= 0; i--) {
      x[s[i] - 'a']--;
      for (long long int j = s[i] - 'a' + 1; j < 26; j++) {
        x[j]++;
        if (sum(x, k) <= n - i - 1) {
          string ans = "";
          for (long long int l = 0; l < i; l++) {
            ans = ans + char(s[l]);
          }
          ans += char(j + 'a');
          vector<long long int> pp(26, 0);
          for (long long int p = 0; p < ans.length(); p++) {
            pp[ans[p] - 'a']++;
          }
          for (long long int p = 0; p < 26; p++) {
            if ((k - pp[p] % k) % k != 0) {
              for (long long int t = 0; t < (k - pp[p] % k) % k; t++) {
                ans += char('a' + p);
              }
            }
          }
          cout << ans << endl;
          flag = 1;
          break;
        }
        x[j]--;
      }
      if (flag == 1) {
        break;
      }
    }
    if (flag == 0) {
      cout << -1 << endl;
    }
  }
}
