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 main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> row(n, 0);
    vector<vector<int>> mat(26, row);
    string inp;
    cin >> inp;
    if (n % k) {
      cout << -1 << endl;
      continue;
    }
    mat[inp[0] - 'a'][0]++;
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < 26; j++) mat[j][i] = mat[j][i - 1];
      mat[inp[i] - 'a'][i]++;
    }
    int valid = 1;
    for (int i = 0; i < 26; i++) {
      if (mat[i][n - 1] % k) {
        valid = 0;
        break;
      }
    }
    if (valid) {
      cout << inp << endl;
      continue;
    }
    int l = 0, r = n - 1;
    while (r - l > 1) {
      int m = (l + r) / 2;
      string cmp(n, '0');
      int ptr = n - 1;
      int sets = 0;
      for (int i = 0; i < 26; i++) {
        int rem = (k - mat[i][m - 1] % k) % k;
        if (rem > 0 && ptr <= m - 1) {
          r = m - 1;
          sets = 1;
          break;
        }
        while (rem > 0 && ptr > m - 1) {
          cmp[ptr] = 'a' + i;
          ptr--;
          rem--;
        }
      }
      if (sets) continue;
      while (ptr > m - 1) {
        cmp[ptr] = 'z';
        ptr--;
      }
      int flag = 1;
      for (int i = m; i < n; i++) {
        if (cmp[i] < inp[i]) {
          flag = 0;
          break;
        } else if (cmp[i] > inp[i])
          break;
      }
      if (flag)
        l = m;
      else
        r = m - 1;
    }
    int pos;
    if (r <= l)
      pos = l;
    else {
      string cmp(n, '0');
      int m = r;
      int ptr = n - 1;
      int sets = 0;
      for (int i = 0; i < 26; i++) {
        int rem = (k - mat[i][m - 1] % k) % k;
        if (rem > 0 && ptr <= m - 1) {
          pos = l;
          sets = 1;
          break;
        }
        while (rem > 0 && ptr > m - 1) {
          cmp[ptr] = 'a' + i;
          ptr--;
          rem--;
        }
      }
      if (!sets) {
        while (ptr > m - 1) {
          cmp[ptr] = 'z';
          ptr--;
        }
        int flag = 1;
        for (int i = m; i < n; i++) {
          if (cmp[i] < inp[i]) {
            flag = 0;
            break;
          } else if (cmp[i] > inp[i])
            break;
        }
        if (flag)
          pos = r;
        else
          pos = l;
      }
    }
    string ans(n, '0');
    for (int i = 0; i < pos; i++) ans[i] = inp[i];
    vector<int> cnt(26, 0);
    for (int i = 0; i < 26; i++) cnt[i] = mat[i][pos - 1];
    cnt[inp[pos] - 'a' + 1]++;
    ans[pos] = inp[pos] + 1;
    int ptr = n - 1;
    for (int i = 25; i >= 0; i--) {
      int rem = (k - cnt[i] % k) % k;
      while (rem > 0 && ptr > pos) {
        ans[ptr] = 'a' + i;
        ptr--;
        rem--;
      }
    }
    while (ptr > pos) {
      ans[ptr] = 'a';
      ptr--;
    }
    cout << ans << endl;
  }
  return 0;
}
