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() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t, i, x, y, m, n, j, k, ans = 0, count = 0, tot = 0, flag, od,
                                        ev, sum, ma, mi;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    string s;
    cin >> s;
    if (n % k != 0) {
      cout << "-1";
    } else {
      i = 0;
      j = n;
      char c;
      ans = -1;
      while (i <= j) {
        x = (i + j) / 2;
        long long int a[26] = {0};
        sum = 0;
        for (y = 0; y < x; y++) {
          a[s[y] - 'a']++;
          a[s[y] - 'a'] = a[s[y] - 'a'] % k;
        }
        for (y = 0; y < 26; y++) {
          if (a[y] % k != 0) {
            c = y + 'a';
            sum += k - a[y];
          }
        }
        if (sum > n - x) {
          j = x - 1;
        } else {
          string l;
          flag = 0;
          for (y = 0; y < x; y++) {
            l.push_back(s[y]);
          }
          for (y = 0; y < n - x - sum; y++) {
            l.push_back('z');
          }
          for (y = 25; y >= 0; y--) {
            if (a[y] > 0) {
              for (m = 0; m < k - a[y]; m++) {
                l.push_back(y + 'a');
              }
            }
          }
          if (l >= s) {
            ans = x;
            i = x + 1;
          } else {
            j = x - 1;
          }
        }
      }
      x = ans;
      for (i = 0; i < x; i++) {
        cout << s[i];
      }
      if (x != n) {
        long long int a[26] = {0};
        sum = 0;
        for (i = 0; i < x; i++) {
          a[s[i] - 'a']++;
          a[s[i] - 'a'] = a[s[i] - 'a'] % k;
        }
        for (i = 0; i < 26; i++) {
          if (a[i] > 0) {
            a[i] = k - a[i];
            sum += a[i];
          }
        }
        char p;
        if (n - x == sum) {
          for (i = s[x] - 'a'; i < 26; i++) {
            if (a[i] > 0) {
              p = 'a';
              p += i;
              cout << p;
              a[i]--;
              break;
            }
          }
          for (i = 0; i < 26; i++) {
            if (a[i] > 0) {
              p = 'a';
              p += i;
              for (j = 0; j < a[i]; j++) {
                cout << p;
              }
            }
          }
        } else {
          if (a[s[x] - 'a' + 1] == 0) {
            p = s[x];
            p++;
            cout << p;
            a[p - 'a'] += k - 1;
            sum += k - 1;
            a[0] += n - x - 1 - sum;
            for (i = 0; i < 26; i++) {
              if (a[i] > 0) {
                p = 'a';
                p += i;
                for (j = 0; j < a[i]; j++) {
                  cout << p;
                }
              }
            }
          } else {
            a[0] += n - x - sum - k;
            cout << s[x]++;
            a[s[x] - 'a']--;
            for (i = 0; i < 26; i++) {
              if (a[i] > 0) {
                p = 'a';
                p += i;
                for (j = 0; j < a[i]; j++) {
                  cout << p;
                }
              }
            }
          }
        }
      }
    }
    cout << "\n";
  }
  return 0;
}
