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;
template <typename F, typename S>
ostream& operator<<(ostream& os, const pair<F, S>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, vector<T> const& x) {
  os << "{ ";
  for (auto& y : x) os << y << " ";
  return os << "}";
}
template <class T>
ostream& operator<<(ostream& os, set<T> const& x) {
  os << "{ ";
  for (auto& y : x) os << y << " ";
  return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  os << "[";
  typename multiset<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream& operator<<(ostream& os, const map<F, S>& v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
const int N = 5050;
map<char, int> mp;
long long int n, k;
int have;
bool is_ok() {
  int cnt = 0, cc = 0;
  for (auto i : mp) {
    if (i.second % k) cnt += k - (i.second % k);
    if (cnt > have) return false;
    cc += i.second;
  }
  cc += cnt;
  if (cc > n) return false;
  if ((n - cc) % k) return false;
  return true;
}
void _main_main() {
  mp.clear();
  cin >> n >> k;
  string s, ans;
  cin >> s;
  if (n % k) {
    cout << -1;
    return;
  }
  for (int i = 0; i < n; i++) mp[s[i]]++;
  have = 0;
  if (is_ok()) {
    cout << s;
    return;
  }
  for (int i = n - 1; i >= 0; i--) {
    have = n - i - 1;
    mp[s[i]]--;
    for (char ch = s[i] + 1; ch <= 'z'; ch++) {
      mp[ch]++;
      if (is_ok()) {
        ans = "";
        for (int j = 0; j < i; j++) ans += s[j];
        ans += ch;
        int cnt = 0;
        for (auto it : mp) {
          if (it.second % k) cnt += it.second;
        }
        while (ans.size() + cnt < n) ans += 'a';
        for (auto it : mp) {
          while (it.second % k) {
            ans += it.first;
            it.second++;
          }
        }
        cout << ans;
        return;
      }
      mp[ch]--;
    }
  }
  cout << -1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int testCase = 1;
  cin >> testCase;
  for (int i = 0; i < testCase; i++) {
    _main_main();
    cout << "\n";
  }
}
