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>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using tl = tuple<ll, ll, ll, ll>;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
using ld = long double;
int TC, N, K;
string S;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> TC;
  while (TC--) {
    cin >> N >> K >> S;
    map<char, int> M, M2;
    if (N % K) {
      cout << "-1\n";
      continue;
    }
    for (int i = (0); i < (N); i++) M[S[i]]++;
    int tmp = 0;
    for (auto [c, cnt] : M) {
      tmp += ((-cnt) % K + K) % K;
    }
    if (tmp == 0) {
      for (int j = (0); j < (N); j++) cout << S[j];
      cout << "\n";
      continue;
    }
    for (int i = (N)-1; i >= (0); i--) {
      M[S[i]]--;
      if (M[S[i]] == 0) M.erase(S[i]);
      int tmp = 0;
      M2.clear();
      for (auto [c, cnt] : M) {
        M2[c] = ((-cnt) % K + K) % K;
        tmp += M2[c];
      }
      auto pos = M2.lower_bound(S[i] + 1);
      if (tmp + i > N || pos == M2.end()) continue;
      for (int j = (0); j < (i); j++) cout << S[j];
      cout << pos->first;
      (pos->second)--;
      for (int _ = (0); _ < (N - 1 - i - tmp); _++) cout << 'a';
      for (auto [c, cnt] : M) {
        for (int _ = (0); _ < (M2[c]); _++) cout << c;
      }
      break;
    }
    cout << "\n";
  }
}
