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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 3e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (a * res) % md;
    }
    a = (a * a) % md;
    b >>= 1;
  }
  return (res);
}
int q;
int n, k;
string s;
int cnt[30], tnc[30];
int hentai[30];
bool chk(int x) {
  int rmn = n - x;
  for (int i = 0; i < 26; i++) rmn -= hentai[i];
  if (rmn < 0) return (0);
  if (rmn % k) return (0);
  hentai[25] += rmn;
  for (int i = 25; i >= 0; i--)
    if (hentai[i] and !tnc[i])
      return (1);
    else if (tnc[i] and !hentai[i])
      return (0);
  return (1);
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> q;
  while (q--) {
    memset(cnt, 0, sizeof cnt);
    memset(tnc, 0, sizeof tnc);
    cin >> n >> k;
    cin >> s;
    int lst = -1;
    s = "8" + s;
    for (int i = 1; i <= n; i++) tnc[s[i] - 'a']++;
    for (int i = 1; i <= n; i++) {
      cnt[s[i] - 'a']++;
      tnc[s[i] - 'a']--;
      memset(hentai, 0, sizeof hentai);
      for (int j = 0; j < 26; j++) hentai[j] = ((k - (cnt[j] % k)) % k);
      if (chk(i)) lst = i;
    }
    if (lst == -1) {
      cout << -1 << '\n';
      continue;
    }
    string ans = "";
    for (int i = 1; i <= lst; i++) ans += s[i];
    memset(cnt, 0, sizeof cnt);
    memset(tnc, 0, sizeof tnc);
    for (int i = 1; i <= n; i++) tnc[s[i] - 'a']++;
    for (int i = 1; i <= lst; i++) {
      cnt[s[i] - 'a']++;
      tnc[s[i] - 'a']--;
      memset(hentai, 0, sizeof hentai);
      for (int j = 0; j < 26; j++) hentai[j] = ((k - (cnt[j] % k)) % k);
    }
    if (lst == n) {
      for (int i = 1; i <= n; i++) cout << s[i];
      cout << '\n';
      continue;
    }
    int rmn = n - lst;
    for (int i = 0; i < 26; i++) rmn -= hentai[i];
    int mx = -1, xm;
    xm = s[lst + 1] - 'a';
    for (int i = 26; i >= 0; i--)
      if (hentai[i] and i > xm) mx = i;
    if (mx > xm) {
      ans += char('a' + mx);
      hentai[mx]--;
      hentai[0] += rmn;
      for (int i = 0; i < 26; i++)
        for (int j = 0; j < hentai[i]; j++) ans += char('a' + i);
    } else {
      if (rmn == 0 or xm + 1 > 25) {
        cout << -1 << '\n';
        continue;
      }
      hentai[xm + 1] += k - 1;
      ans += char('a' + xm + 1);
      rmn -= k;
      hentai[0] += rmn;
      for (int i = 0; i < 26; i++)
        for (int j = 0; j < hentai[i]; j++) ans += char('a' + i);
    }
    cout << ans << '\n';
  }
  return (0);
}
