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;
bool good(string second, int k) {
  vector<int> first(26);
  for (char& c : second) first[c - 'a']++;
  for (int i = 0; i < 26; i++) {
    if (first[i] % k > 0) return 0;
  }
  return 1;
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    char c;
    cin >> c;
    a[i] = c - 'a';
  }
  if (n % k) {
    cout << -1 << '\n';
    return;
  }
  vector<int> first(26);
  for (int i = 1; i <= n; i++) first[a[i]]++;
  bool same = 1;
  for (int i = 0; i < 26; i++) {
    if (first[i] % k) same = 0;
  }
  if (same) {
    for (int i = 1; i <= n; i++) cout << char(a[i] + 'a');
    cout << '\n';
    return;
  }
  for (int pre = n - 1; pre >= 0; pre--) {
    first[a[pre + 1]]--;
    int room = n - pre - 1;
    for (int i = a[pre + 1] + 1; i < 26; i++) {
      first[i]++;
      int need = 0;
      for (int j = 0; j < 26; j++) {
        if (first[j] % k) need += k - (first[j] % k);
      }
      if (need <= room && (room - need) % k == 0) {
        string second = "";
        int fgreed = room - need;
        bool wtf = 0;
        assert(pre + fgreed + need + 1 == n);
        int g = 0;
        for (int j = 1; j <= pre; j++) {
          second += char(a[j] + 'a');
          g++;
        }
        second += char(i + 'a');
        g++;
        assert(g == pre + 1);
        for (int j = 0; j < 26; j++) {
          if (first[j] % k) {
            if (!wtf) {
              for (int p = 0; p < fgreed; p++) {
                second += char(j + 'a');
                g++;
              }
              wtf = 1;
            }
            for (int p = 0; p < k - (first[j] % k); p++) {
              second += char(j + 'a');
              g++;
            }
          }
        }
        cout << second << '\n';
        return;
      }
      first[i]--;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
