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;
void solve() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (n % k) {
    cout << -1 << endl;
    return;
  }
  int vis[26] = {0};
  for (auto x : s) vis[x - 'a']++;
  int flag = 0;
  for (int i = 0; i < 26; i++)
    if (vis[i] % k) flag = 1;
  if (flag == 0) {
    cout << s << endl;
    return;
  }
  int lo = 0;
  int hi = n;
  int common;
  int ans[26];
  int c;
  while (lo + 1 < hi) {
    string temp = "";
    int mid = (lo + hi) / 2;
    int cnt[26] = {0};
    for (int i = 0; i < mid; i++) {
      temp.push_back(s[i]);
      cnt[s[i] - 'a']--;
      cnt[s[i] - 'a'] %= k;
      if (cnt[s[i] - 'a'] < 0) cnt[s[i] - 'a'] += k;
    }
    flag = 0;
    for (int x = (s[mid] - 'a') + 1; x < 26; x++) {
      flag = 0;
      cnt[x]--;
      cnt[x] %= k;
      if (cnt[x] < 0) cnt[x] += k;
      int tot = accumulate(cnt, cnt + 26, 0);
      if (tot > n - mid - 1) {
        cnt[x] = (cnt[x] + 1) % k;
        continue;
      }
      ans[0] = cnt[0] + (n - mid - 1 - tot);
      for (int i = 1; i < 26; i++) {
        ans[i] = cnt[i];
      }
      flag = 1;
      common = mid;
      c = x;
      break;
    }
    if (flag)
      lo = mid;
    else
      hi = mid;
  }
  string res = "";
  for (int i = 0; i < common; i++) {
    res.push_back(s[i]);
  }
  res.push_back(((char)c + 'a'));
  for (int i = 0; i < 26; i++) {
    while (ans[i]) {
      res.push_back(((char)i + 'a'));
      ans[i]--;
    }
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
