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 a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
inline long long max(long long a, long long b) { return ((a > b) ? a : b); }
inline long long min(long long a, long long b) { return ((a > b) ? b : a); }
long long power(long long x, long long ex);
long long powermod(long long x, long long ex, long long md);
const long long inf = 1e18 + 9;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
const long double eps = 1e-9;
const long long N = 1e5 + 11;
bool iscorrect(string second, long long n, long long k) {
  long long ct[26] = {0};
  for (int i = 0; i < n; i++) ct[second[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if (ct[i] % k) return 0;
  return 1;
}
string generate(string second, long long index, long long n, long long k) {
  string ans;
  map<long long, long long> m;
  for (int i = 0; i <= index - 1; i++) {
    ans.push_back(second[i]);
    long long x = second[i] - 'a';
    auto it = m.find(x);
    if (it == m.end()) {
      m[x] += k;
    }
    m[x]--;
    if (m[x] == 0) m.erase(m.find(x));
  }
  long long ct = 0, rem = (n - 1 - (index) + 1);
  bool use_extra = 0;
  for (auto it = m.begin(); it != m.end(); it++) ct += (it->second);
  if (ct > rem)
    return "";
  else if (ct < rem)
    use_extra = 1;
  if (second[index] == 'z') return "";
  auto it = m.upper_bound(second[index] - 'a');
  if (it == m.end()) {
    if (!use_extra) return "";
    long long dif = rem - ct;
    long long add = (second[index] + 1) - 'a';
    m[add] += k;
    ans.push_back(add + 'a');
    m[add] -= 1;
    if (m[add] == 0) m.erase(m.find(add));
    dif -= k;
    m[0] += dif;
  } else {
    long long use = (it->first);
    long long add = (second[index] + 1) - 'a';
    if (use_extra) {
      long long dif = rem - ct;
      if (use > add) {
        m[add] += k;
        ans.push_back(add + 'a');
        m[add] -= 1;
        if (m[add] == 0) m.erase(m.find(add));
        dif -= k;
        m[0] += dif;
      } else {
        ans.push_back(use + 'a');
        m[use] -= 1;
        if (m[use] == 0) m.erase(m.find(use));
        m[0] += dif;
      }
    } else {
      ans.push_back(use + 'a');
      m[use]--;
      if (m[use] == 0) m.erase(m.find(use));
    }
  }
  while (!m.empty()) {
    long long ele = (m.begin())->first;
    long long ct = m[ele];
    for (int i = 0; i < ct; i++) ans.push_back(ele + 'a');
    m.erase(m.find(ele));
  }
  return ans;
}
bool check(string second, long long pos, long long n, long long k) {
  string ans = generate(second, pos, n, k);
  return (ans >= second);
}
void solve() {
  long long n, k;
  cin >> n >> k;
  string second;
  cin >> second;
  if (n % k != 0) {
    cout << -1 << "\n";
    return;
  }
  if (iscorrect(second, n, k)) {
    cout << second << "\n";
    return;
  }
  long long l = 0, r = n - 1, ans = -1;
  while (l <= r) {
    long long mid = (l + (r - l) / 2);
    if (check(second, mid, n, k)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  if (ans == -1) {
    iscorrect(second, n, k) ? cout << second << "\n" : cout << -1 << "\n";
  } else {
    string final = generate(second, ans, n, k);
    iscorrect(final, n, k) ? cout << final << "\n" : cout << -1 << "\n";
  }
}
int main() {
  {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  cout << fixed << setprecision(20);
  long long NTC = 1;
  cin >> NTC;
  long long PTC = 0;
  while ((PTC++) < NTC) {
    solve();
  }
}
long long power(long long x, long long y) {
  if (y == 0) return 1;
  long long a = power(x, y / 2);
  if (y % 2 == 0)
    return a * a;
  else
    return x * a * a;
}
long long powermod(long long x, long long ex, long long md) {
  long long ans = 1ll;
  while (ex > 0) {
    if (ex & 1ll) ans = (ans * x) % md;
    ex >>= 1ll;
    x = (x * x) % md;
  }
  return ans;
}
