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;
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long MOD2 = 998244353;
const long long N = 1000 * 100 + 10;
const long long N2 = 70;
const long double PI = 3.141592653589793;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
string check(string s, long long mid, long long k) {
  map<char, long long> m, have;
  for (long long i = 0; i < mid; ++i) {
    m[s[i]]++;
  }
  long long n = s.size();
  long long left = n - mid;
  bool good = true;
  long long remain = 0;
  for (auto x : m) {
    long long req = x.second % k;
    if (req) {
      req = k - req;
      have[x.first] = req;
      left -= req;
      remain += req;
      good = false;
    }
  }
  if (left < 0) return "#";
  string ans = s;
  while (mid != n && ans[mid] == 'z') {
    left--;
    mid++;
  }
  remain += left;
  if (mid == n && good) return ans;
  if (mid == n && !good) return "#";
  char next = ans[mid] + 1;
  if (left >= k && have.find(next) == have.end()) {
    have[next] = k;
    left -= k;
  }
  have['a'] += left;
  bool ok = false;
  for (long long i = 0; i < 26; i++) {
    char c = i + 'a';
    if (have[c]) {
      if (c > ans[mid]) {
        ok = true;
        ans[mid] = c;
        have[c]--;
        remain--;
        break;
      }
    }
  }
  if (!ok) return "#";
  long long cur = 0;
  for (long long i = mid + 1; i < n; i++) {
    while (cur != 26 and have[cur + 'a'] == 0) cur++;
    ans[i] = cur + 'a';
    remain--;
    have[cur + 'a']--;
  }
  if (remain) return "#";
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (n % k) {
      cout << -1 << "\n";
      continue;
    }
    long long low = 0, high = n, mid;
    string ans;
    while (high >= low) {
      mid = (high + low) / 2;
      string temp = check(s, mid, k);
      if (temp == "#") {
        high = mid - 1;
      } else {
        low = mid + 1;
        ans = temp;
      }
    }
    cout << ans << "\n";
  }
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  ;
  return 0;
}
