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;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
const long long INF = numeric_limits<long long>::max();
const long double PI = 3.1415926535898;
const long long MOD = 1000000007;
const long long LIM = 100005;
long long fpow(long long x, long long y) {
  long long temp;
  if (y == 0) return 1;
  temp = fpow(x, y / 2);
  if (y % 2 == 0)
    return (temp * temp) % MOD;
  else
    return x * ((temp * temp) % MOD) % MOD;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long modInverse(long long n, long long p) { return fpow(n, p - 2); }
map<long long, long long> primeFactors(long long n) {
  map<long long, long long> mp;
  while (n % 2 == 0) {
    if (mp.count(2) == 1)
      mp[2]++;
    else
      mp.insert({2, 1});
    n = n / 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      if (mp.count(i) == 1)
        mp[i]++;
      else
        mp.insert({i, 1});
      n = n / i;
    }
  }
  if (n > 2) {
    if (mp.count(n) == 1)
      mp[n]++;
    else
      mp.insert({n, 1});
  }
  return mp;
}
long long spf[LIM];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < LIM; i++) spf[i] = i;
  for (long long i = 4; i < LIM; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < LIM; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < LIM; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getFactorization(long long x) {
  map<long long, long long> ret;
  while (x != 1) {
    ret[spf[x]]++;
    x = x / spf[x];
  }
  return ret;
}
long long dp[LIM][26];
bool solve(long long index, char ch, long long k, long long n) {
  long long sum = 0;
  if (index > 0) {
    for (long long i = 0; i < 26; i++) {
      if (i == ch - 'a') continue;
      if (dp[index - 1][i] % k > 0) sum += k - dp[index - 1][i] % k;
    }
    if ((dp[index - 1][ch - 'a'] + 1) % k > 0)
      sum += k - (dp[index - 1][ch - 'a'] + 1) % k;
  } else {
    if (1 % k > 0) sum += k - 1 % k;
  }
  if (sum > n - 1 - index || ((n - 1 - index) - sum) % k > 0)
    return false;
  else
    return true;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long tt = 1; tt <= t; ++tt) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (long long i = 0; i <= n; i++)
      for (long long j = 0; j < 26; j++) dp[i][j] = 0;
    if (n % k != 0) {
      cout << -1 << "\n";
      continue;
    }
    dp[0][s[0] - 'a']++;
    for (long long i = 1; i < n; i++) {
      for (long long j = 0; j < 26; j++) dp[i][j] = dp[i - 1][j];
      dp[i][s[i] - 'a']++;
    }
    if (solve(n - 1, s[n - 1], k, n)) {
      cout << s << "\n";
      continue;
    }
    for (long long i = n - 1; i >= 0; i--) {
      for (char j = s[i] + 1; j <= 'z'; j++) {
        if (solve(i, j, k, n) == false) continue;
        vector<char> v;
        if (i > 0) {
          for (long long l = 0; l < 26; l++) {
            if (l == j - 'a') continue;
            if (dp[i - 1][l] % k > 0) {
              for (long long m = 0; m < k - dp[i - 1][l] % k; m++)
                v.push_back(l + 'a');
            }
          }
          if ((dp[i - 1][j - 'a'] + 1) % k > 0) {
            for (long long m = 0; m < k - (dp[i - 1][j - 'a'] + 1) % k; m++)
              v.push_back(j);
          }
        } else {
          if (1 % k > 0) {
            for (long long m = 0; m < k - 1 % k; m++) v.push_back(j);
          }
        }
        for (long long l = 0; l < n - 1 - i - v.size(); l++) v.push_back('a');
        sort(v.begin(), v.end());
        ;
        cout << s.substr(0, i) << j;
        for (auto ch : v) cout << ch;
        cout << "\n";
        goto jump;
      }
    }
  jump:;
  }
  return 0;
}
