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;
long long mM(long long a, long long b, long long p = 1000000007) {
  long long res = 0;
  if (a >= p) a %= p;
  while (b) {
    if (b & 1ll) res = (res + a);
    if (res >= p) res %= p;
    a = (2 * a);
    if (a >= p) a %= p;
    b >>= 1ll;
  }
  return res;
}
long long fpow(long long first, long long second, long long p = 1000000007) {
  if (first >= p) first = first % p;
  long long res = 1;
  while (second) {
    if (second & 1ll) res *= first;
    if (res < 0) res += p;
    if (res >= p) res %= p;
    second = second >> 1ll;
    first *= first;
    if (first < 0) first += p;
    if (first >= p) first %= p;
  }
  return res;
}
long long inv(long long n, long long p = 1000000007) {
  return fpow(n, p - 2, p);
}
long long modmul(long long first, long long second, long long p = 1000000007) {
  if (first < 0) first += p;
  if (first >= p) first %= p;
  if (second < 0) second += p;
  if (second >= p) second %= p;
  return (first * second) % p;
}
long long modadd(long long first, long long second, long long p = 1000000007) {
  if (first < 0) first += p;
  if (first >= p) first %= p;
  if (second < 0) second += p;
  if (second >= p) second %= p;
  long long temp = first + second;
  if (temp >= p) temp %= p;
  return temp;
}
void print(vector<int> a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
  cout << "\n";
}
int main() {
  long long t = 1, tc = 0;
  cin >> t;
  while (t--) {
    int n, k;
    string s;
    cin >> n >> k >> s;
    if (n % k) {
      cout << "-1\n";
      continue;
    }
    vector<vector<int> > pre(n, vector<int>(26, 0));
    pre[0][s[0] - 'a']++;
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < 26; j++) pre[i][j] = pre[i - 1][j];
      pre[i][s[i] - 'a']++;
    }
    int ind = -1;
    bool ok = false;
    string q = "", r = "";
    char c;
    bool ok1 = false;
    int sum = 0;
    for (int i = 0; i < 26; i++) {
      sum += (pre[n - 1][i] % k);
    }
    if (sum == 0) {
      cout << s << "\n";
      continue;
    }
    for (int i = s.size() - 1; i >= 0; i--) {
      int cur = s[i] - 'a';
      for (int j = cur + 1; j < 26; j++) {
        vector<int> pre1(26, 0);
        if (i) {
          pre1 = pre[i - 1];
        }
        pre1[j]++;
        for (int l = 0; l < 26; l++) pre1[l] %= k;
        int sum = 0;
        for (int l = 0; l < 26; l++) sum += pre1[l];
        if (sum <= (n - i)) {
          ok = true;
          for (int l = 0; l < 26; l++) {
            for (int r = 0; r < pre1[l]; r++) q += char(l + 'a');
          }
          for (int l = 0; l < i; l++) r += s[l];
          c = char(j + 'a');
          while ((q.size() + r.size() + 1) < n) {
            q += 'a';
          }
          sort((q).begin(), (q).end());
          break;
        }
      }
      if (ok) {
        break;
      }
    }
    if (!ok) {
      cout << "-1\n";
      continue;
    }
    cout << r << c << q << "\n";
  }
}
