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 comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first < b.first;
}
bool comps(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second == b.second) return a.first < b.first;
  return a.second < b.second;
}
bool compmx(int a, int b) { return (a < b); }
void fastio() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
void inout() {}
long long int inf = 1E9 + 7;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
bool chk(long long int n, long long int k, vector<long long int> a,
         long long int i) {
  long long int cnt = 0;
  for (long long int j = 0; j < 26; j++) {
    cnt += (k - a[i] % k) % k;
  }
  if (n - i - 1 >= cnt)
    return true;
  else
    return false;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (n % k)
      cout << -1;
    else {
      vector<long long int> a(26, 0);
      for (long long int i = 0; i < n; i++) {
        a[s[i] - 'a']++;
      }
      long long int flag = 1;
      for (long long int i = 0; i < 26; i++) {
        if (a[i] % k != 0) flag = 0;
      }
      if (flag)
        cout << s;
      else {
        for (long long int i = n - 1; i >= 0; i += -1) {
          long long int places = 0;
          for (long long int l = s[i] + 1 - 'a'; l < 26; l += 1) {
            long long int cnt = 0;
            for (long long int j = 0; j < 26; j++) {
              if (j == l)
                cnt += (k - (a[j] + 1) % k) % k;
              else if (j == s[i] - 'a')
                cnt += (k - (a[j] - 1) % k) % k;
              else
                cnt += (k - (a[j]) % k) % k;
            }
            if (cnt <= n - i - 1 && (n - i - i - cnt) % k == 0) {
              string f;
              for (long long int j = 0; j < i; j++) f += s[j];
              char c = 'a' + l;
              f += c;
              a[s[i] - 'a']--;
              a[l]++;
              long long int y = 0;
              for (long long int j = 0; j < 26; j++) {
                y = (k - (a[j]) % k) % k;
                for (long long int r = 0; r < y; r++) {
                  char c = 'a' + j;
                  f += c;
                }
              }
              cout << f << " ";
              goto here;
            }
          }
          a[s[i] - 'a']--;
        }
      }
    }
  here:
    cout << "\n";
    ;
  }
  return 0;
}
