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;
namespace my_template {
vector<vector<long long>> primes;
vector<vector<long long>> facts;
vector<long long> factorialNumInverse;
vector<long long> naturalNumInverse;
vector<long long> factorials;
long long big = 1e9 + 7;
void InverseofNumber(long long N, long long p = big) {
  naturalNumInverse[0] = naturalNumInverse[1] = 1;
  for (long long i = 2; i <= N; i++)
    naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
void InverseofFactorial(long long N, long long p = big) {
  factorialNumInverse[0] = factorialNumInverse[1] = 1;
  for (long long i = 2; i <= N; i++)
    factorialNumInverse[i] =
        (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}
void factorial(long long N, long long p = big) {
  factorials[0] = 1;
  for (long long i = 1; i <= N; i++) {
    factorials[i] = (factorials[i - 1] * i) % p;
  }
}
void setncr(long long size = 1e5 + 1, long long p = big) {
  factorialNumInverse.resize(size);
  naturalNumInverse.resize(size);
  factorials.resize(size);
  InverseofNumber(size, p);
  factorial(size, p);
  InverseofFactorial(size, p);
}
long long ncr(long long N, long long R, long long p = big) {
  long long ans = ((factorials[N] * factorialNumInverse[R]) % p *
                   factorialNumInverse[N - R]) %
                  p;
  return ans;
}
long long power(long long a, long long b, long long m = big) {
  if (b == 0) return 1;
  long long ans = power(a, b / 2, m);
  if (b % 2 == 0) return ans * ans % m;
  return ((a * ans) % m * ans) % m;
}
long long inverse(long long a, long long m = big) { return power(a, m - 2, m); }
long long ceil(long long a, long long b) {
  if (a == 0) return 0;
  return (a - 1) / b + 1;
}
void init_prime(long long size = 1e6 + 1) {
  primes.resize(size);
  for (long long i = 2; i < size; i++) {
    if (primes[i].size() == 0) {
      for (long long j = i; j < size; j += i) primes[j].push_back(i);
    }
  }
}
void init_facts(long long size = 2e5 + 1) {
  facts.resize(size);
  for (long long i = 1; i < size; i++) {
    for (long long j = i; j < size; j += i) facts[j].push_back(i);
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename T>
vector<long long> argsort(const vector<T> &v, bool reverse = false) {
  vector<long long> idx(v.size());
  iota(idx.begin(), idx.end(), 0);
  if (reverse == false)
    stable_sort(idx.begin(), idx.end(),
                [&v](long long i1, long long i2) { return v[i1] < v[i2]; });
  else
    stable_sort(idx.begin(), idx.end(),
                [&v](long long i1, long long i2) { return v[i1] > v[i2]; });
  return idx;
}
}  // namespace my_template
using namespace my_template;
void solve();
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
long long k;
string s;
bool possible(long long l) {
  long long n = s.length();
  if (l > n) return false;
  long long postot = n / k;
  vector<long long> count(26, 0);
  for (long long i = 0; i < l; i++) {
    count[s[i] - 'a']++;
  }
  long long tot1 = 0;
  for (long long i = 0; i < 26; i++) {
    tot1 += ceil(count[i], k);
    count[i] = ceil(count[i], k) * k - count[i];
  }
  if (tot1 > postot) return false;
  count[25] += (postot - tot1) * k;
  if (l == n) return true;
  for (long long i = s[l] - 'a'; i < 26; i++) {
    if (count[i] > 0) return true;
  }
  return false;
}
string mini(long long l) {
  long long n = s.length();
  if (l == n) return s;
  string ans = s.substr(0, l);
  long long postot = n / k;
  vector<long long> count(26, 0);
  for (long long i = 0; i < l; i++) {
    count[s[i] - 'a']++;
  }
  long long tot1 = 0;
  for (long long i = 0; i < 26; i++) {
    tot1 += ceil(count[i], k);
    count[i] = ceil(count[i], k) * k - count[i];
  }
  char nex = '$';
  for (long long i = s[l] - 'a'; i < 26; i++) {
    if (count[i] > 0) {
      nex = 'a' + i;
      break;
    }
  }
  if (nex == '$') {
    assert(s[l] != 'z');
    assert(tot1 < postot);
    tot1++;
    count[s[l] + 1 - 'a'] += k;
    nex = s[l] + 1;
  }
  ans.push_back(nex);
  count[nex - 'a']--;
  count[0] += (postot - tot1) * k;
  for (long long i = 0; i < 26; i++) {
    while (count[i] > 0) {
      ans.push_back(i + 'a');
      count[i]--;
    }
  }
  return ans;
}
void solve() {
  long long n;
  cin >> n >> k >> s;
  if (n % k != 0) {
    cout << -1 << endl;
    return;
  }
  long long l = 0, r = n;
  long long m;
  while (l + 1 < r) {
    m = (l + r) / 2;
    if (possible(m))
      l = m;
    else
      r = m - 1;
  }
  if (possible(r))
    cout << mini(r) << endl;
  else
    cout << mini(l) << endl;
}
