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>
int dx[2] = {0, 1};
int dy[2] = {1, 0};
long long GCD(long long a, long long b) { return (a) ? GCD(b % a, a) : b; }
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
long long fastpow(long long b, long long p) {
  if (!p) return 1;
  long long ret = fastpow(b, p >> 1);
  ret *= ret;
  if (p & 1) ret *= b;
  return ret;
}
using namespace std;
bool adsf;
void solve() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (n % k) {
    cout << -1 << '\n';
    return;
  }
  int allowed = n / k;
  unordered_map<int, int> m, m2;
  for (auto x : s) {
    m[x - 'a']++;
  }
  bool firstcheck = true;
  for (auto x : s) {
    if (m[x - 'a'] % k) firstcheck = false;
  }
  if (firstcheck) {
    cout << s << '\n';
    return;
  }
  int rem, abbas, abbas2;
  bool flag;
  int done = -1;
  string s2;
  int fistbigger, fistbigger2 = 'z' - 'a' + 1;
  for (int i = n - 1; i >= 0; i--) {
    rem = 0;
    fistbigger2 = 'z' - 'a' + 1;
    m[s[i] - 'a']--;
    flag = m[s[i] - 'a' + 1];
    for (auto x : m) {
      if (x.second && x.first + 'a' > s[i] && x.first < fistbigger2)
        fistbigger2 = x.first;
      rem += x.second % k == 0 ? 0 : k - (x.second % k);
    }
    fistbigger = s[i] - 'a' + 1;
    abbas = k - (m[fistbigger] % k);
    rem -= m[fistbigger] % k == 0 ? 0 : k - (m[fistbigger] % k);
    if (rem + abbas <= n - i && s[i] != 'z')
      ;
    else if (fistbigger2 < 'z' - 'a' + 1) {
      rem += m[fistbigger] % k == 0 ? 0 : k - (m[fistbigger] % k);
      fistbigger = fistbigger2;
      abbas = k - (m[fistbigger] % k);
      rem -= m[fistbigger] % k == 0 ? 0 : k - (m[fistbigger] % k);
    }
    if (rem + abbas <= n - i && s[i] != 'z') {
      done = i;
      for (auto x : m) {
        if (x.first == fistbigger) {
          continue;
        }
        abbas2 = x.second % k == 0 ? 0 : k - (x.second % k);
        for (int j = 0; j < abbas2; j++) s2 += x.first + 'a';
      }
      for (int j = 1; j < abbas; j++) s2 += fistbigger + 'a';
      break;
    }
  }
  if (done == -1) {
    cout << -1 << '\n';
    return;
  }
  string s3(n - done - 1 - s2.size(), 'a');
  sort(s2.begin(), s2.end());
  if (adsf) return;
  for (int i = 0; i < done; i++) cout << s[i];
  cout << char(fistbigger + 'a');
  cout << s3 << s2 << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int TT = 1;
  cin >> TT;
  int jj = 1;
  while (TT--) {
    if (TT == 7081) adsf = true;
    if (TT == 7081 && jj == 329) {
      int n, k;
      string s;
      cin >> n >> k >> s;
      cout << n << '\n' << k << '\n' << s;
    }
    solve();
    jj++;
  }
}
