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;
inline long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }
const long long mod = 1e9 + 7;
inline long long QPow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long exgcd(long long a, long long b, long long &x, long long &y) {
  long long d = a;
  if (b == 0)
    x = 1, y = 0;
  else {
    d = exgcd(b, a % b, y, x), y -= a / b * x;
  }
  return d;
}
const long long maxn = 200005;
long long cnt[26];
long long ls[26];
string str;
string tmp;
long long n, k;
inline bool check(signed md) {
  if (md > n) return 0;
  tmp.clear();
  memset(cnt, 0, sizeof cnt);
  tmp.push_back(' ');
  for (long long i = 1; i <= md; i++) {
    cnt[str[i] - 'a']++;
    tmp.push_back(str[i]);
  }
  long long tot = 0;
  long long les = 0;
  for (long long i = 0; i < 26; i++) ls[i] = (k - cnt[i] % k) % k, tot += ls[i];
  les = n - md - tot;
  if (les < 0) return 0;
  ls[25] += les;
  long long ptr = 25;
  for (long long i = md + 1; i <= n; i++) {
    while (ptr >= 0 && ls[ptr] == 0) ptr--;
    ls[ptr]--;
    tmp.push_back(ptr + 'a');
  }
  for (long long i = 1; i <= n; i++)
    if (str[i] > tmp[i])
      return 0;
    else if (str[i] < tmp[i])
      return 1;
  return 1;
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t, q, h, m;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    cin >> str;
    if (n % k != 0) {
      cout << -1 << '\n';
      continue;
    }
    str = " " + str;
    long long lef = 1;
    long long rig = n;
    long long md = (lef + rig) >> 1;
    while (lef <= rig) {
      md = (lef + rig) >> 1;
      if (check(md))
        lef = md + 1;
      else
        rig = md - 1;
    }
    if (check(md + 1)) md++;
    if (check(md) == 0) md--;
    memset(cnt, 0, sizeof cnt);
    tmp.clear();
    for (long long i = 1; i <= md; i++)
      cnt[str[i] - 'a']++, tmp.push_back(str[i]);
    long long tot = 0;
    for (long long i = 0; i < 26; i++)
      ls[i] = (k - cnt[i] % k) % k, tot += ls[i];
    if (md < n) {
      bool flag = 0;
      for (long long i = 0; i < 26; i++) {
        if (ls[i] && i > str[md + 1] - 'a') {
          tmp.push_back('a' + i), ls[i]--;
          flag = 1;
          break;
        }
      }
      if (!flag) {
        tmp.push_back(char(str[md + 1] + 1));
        ls[str[md + 1] - 'a' + 1] += k - 1;
        tot += k;
      }
      long long les = n - md - tot;
      ls[0] += les;
      long long ptr = 0;
      while (ptr < 26) {
        while (ptr < 26 && ls[ptr] == 0) ptr++;
        if (ptr >= 26) break;
        tmp.push_back(ptr + 'a');
        ls[ptr]--;
      }
    }
    cout << tmp << '\n';
  }
  return 0;
}
