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 = 100005;
int n, k;
char s[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k >> (s + 1);
    if (n % k) {
      cout << -1 << '\n';
      continue;
    }
    int C[26] = {}, fail = 0, sum;
    for (int i = 1; i <= n; i++) ++C[s[i] - 'a'];
    for (int i = 0; i < 26; i++) fail |= C[i] % k != 0;
    if (!fail) {
      cout << (s + 1) << '\n';
      continue;
    }
    int ok = 0;
    for (int i = n; i >= 1 && !ok; i--) {
      --C[s[i] - 'a'];
      for (int j = s[i] - 'a' + 1; j < 26; j++) {
        ++C[j];
        sum = 0;
        for (int ch = 0; ch < 26; ch++) sum += (k - C[ch] % k) % k;
        if (sum > n - i) {
          --C[j];
          continue;
        }
        for (int jj = 1; jj < i; jj++) cout << s[jj];
        cout << (char)('a' + j);
        for (int ch = 0; ch < 26; ch++)
          for (int p = 0; p < (k - C[ch] % k) % k; p++)
            cout << (char)('a' + ch);
        cout << '\n';
        ok = 1;
        break;
      }
    }
  }
  return 0;
}
