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 int mod = 1e9 + 7;
long long int mul(long long int a, long long int b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long int add(long long int a, long long int b) {
  return ((a % mod) + (b % mod)) % mod;
}
long long int sub(long long int a, long long int b) {
  return ((a % mod) - (b % mod) + mod) % mod;
}
long long int po(long long int a, long long int b) {
  if (b == 0) {
    return 1;
  }
  long long int t = po(a, b / 2);
  if (b % 2) {
    return mul(t, mul(t, a));
  } else {
    return mul(t, t);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, d;
    cin >> n >> d;
    string s;
    cin >> s;
    if (n % d) {
      cout << "-1\n";
      continue;
    }
    map<char, long long int> m;
    string out = "";
    for (long long int i = 0; i < n; i++) {
      out += 'z';
      m[s[i]]++;
    }
    bool f = 1;
    for (char c = 'a'; c <= 'z'; c++) {
      if (m[c] % d) {
        f = 0;
      }
    }
    if (f) {
      cout << s << "\n";
      continue;
    }
    string oo = s;
    for (long long int i = n - 1; i >= 0; i--) {
      s = oo;
      m[s[i]]--;
      if (s[i] == 'z') {
        continue;
      }
      f = 0;
      for (char k = s[i] + 1; k <= 'z'; k++) {
        s = oo;
        long long int x = 0;
        m[k]++;
        for (char c = 'a'; c <= 'z'; c++) {
          if (m[c] % d) {
            long long int z = m[c] % d;
            z = d - z;
            x += (z);
          }
        }
        x = (n - i) - x - 1;
        if (x >= 0 && x % d == 0) {
          char cc = s[i];
          s[i] = k;
          long long int j = i + 1;
          for (char c = 'a'; c <= 'z'; c++) {
            while (m[c] % d) {
              s[j] = c;
              m[c]++;
              j++;
            }
          }
          while (j < n) {
            for (char c = 'a'; c <= 'z'; c++) {
              if (m[c]) {
                s[j] = c;
                j++;
                break;
                ;
              }
            }
          }
          f = 1;
          out = min(out, s);
        }
        m[k]--;
      }
      if (f) {
        break;
      }
    }
    cout << out << "\n";
  }
  return 0;
}
