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;
struct custom {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
const long long inf = 4e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m, i, a, b, c, d, x, y, r, k, j;
    cin >> n >> k;
    string s;
    cin >> s;
    long long cnt[27] = {0};
    if (n % k) {
      cout << -1 << '\n';
      continue;
    }
    for (i = 0; i < s.size(); i++) cnt[s[i] - 'a']++;
    c = 0;
    for (i = 0; i <= 25; i++) {
      if (cnt[i] % k) {
        c = 1;
        break;
      }
    }
    if (!c) {
      cout << s << '\n';
      continue;
    }
    c = 0;
    memset(cnt, 0, sizeof(cnt));
    char ch = 'a';
    ch--;
    for (i = 1; i < s.size(); i++) {
      cnt[s[i - 1] - 'a']++;
      ch = max(ch, s[i - 1]);
      if (s[i] == 'z') continue;
      x = 0;
      for (j = 0; j <= 25; j++) x = x + (k - (cnt[j] % k)) % k;
      if (x > n - i) continue;
      if (x == n - i && ch <= s[i]) continue;
      c = i;
    }
    string s1, s2;
    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < c; i++) {
      s1.push_back(s[i]);
      cnt[s[i] - 'a']++;
    }
    for (i = 0; i <= 25; i++) {
      a = (k - cnt[i] % k) % k;
      ch = 'a' + i;
      for (j = 0; j < a; j++) s2.push_back(ch);
    }
    if (s2.size() < n - c) {
      ch = s[c];
      ch++;
      s1.push_back(ch);
      for (j = 0; j < k - 1; j++) s2.push_back(ch);
      for (j = 0; j < n - c - s2.size() - 1; j++) s2.push_back('a');
      sort(s2.begin(), s2.end());
      cout << s1 << s2 << '\n';
    } else {
      sort(s2.begin(), s2.end());
      for (j = 0; j < s2.size(); j++) {
        if (s2[j] > s[c]) {
          ch = s2[j];
          break;
        }
      }
      s1.push_back(ch);
      string s3;
      for (i = 0; i < s2.size(); i++) {
        if (i == j) continue;
        s3.push_back(s2[i]);
      }
      cout << s1 << s3 << '\n';
    }
  }
}
