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 A, typename B>
string to_string(pair<A, B> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(const char& ch) { return "'" + string(1, ch) + "'"; }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
template <typename T>
using mxpq = priority_queue<T>;
template <typename T>
using mnpq = priority_queue<T, vector<T>, greater<T>>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int64_t rand(int64_t a, int64_t b) {
  return uniform_int_distribution<int64_t>(a, b)(rng);
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& a) {
  out << a.first << " " << a.second;
  return out;
}
template <class A, size_t S>
istream& operator>>(istream& in, array<A, S>& a) {
  for (A& x : a) in >> x;
  return in;
}
template <class A, size_t S>
ostream& operator<<(ostream& out, array<A, S>& a) {
  bool f = false;
  for (A& x : a) {
    if (f) out << " ";
    out << x;
    f = true;
  }
  return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
  for (T& x : a) in >> x;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& a) {
  bool f = false;
  for (T& x : a) {
    if (f) out << " ";
    out << x;
    f = true;
  }
  return out;
}
void out(bool ok, bool cap = true) {
  if (cap)
    cout << (ok ? "YES" : "NO") << '\n';
  else
    cout << (ok ? "Yes" : "No") << '\n';
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const int64_t mod = 1e9 + 7;
const int64_t INF = 1e18L + 5;
const int64_t N = 2e5 + 5;
void solve(int64_t tt) {
  if (tt > 12 && tt < 272) {
    return;
  }
  int64_t n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (tt == 272) {
    cout << "The testcase is :- \n1\n";
    cout << n << " " << k << '\n';
    cout << s << '\n';
    exit(0);
  }
  if (n % k) {
    cout << -1 << '\n';
    return;
  }
  {
    vector<int64_t> temp(26, 0);
    for (int64_t i = 0; i < n; i++) {
      temp[s[i] - 'a']++;
    }
    bool ok = true;
    for (int64_t i = 0; i < 26; i++) {
      if (temp[i] % k) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << s << '\n';
      return;
    }
  }
  vector<int64_t> cnt(26, 0);
  vector<int64_t> sum(n, 0);
  vector<char> extra_ch(n, '?');
  auto get_cost = [&](int64_t val) { return (k - (val % k)) % k; };
  int64_t i = 0;
  int64_t max_i = -1;
  for (; i < n; i++) {
    for (int64_t j = s[i] - 'a' + 1; j < 26; j++) {
      int64_t cost = get_cost(cnt[j] + 1) - get_cost(cnt[j]);
      if ((i > 0 ? sum[i - 1] + cost : cost) <= n - 1 - i) {
        extra_ch[i] = (char)('a' + j);
        max_i = i;
        break;
      }
    }
    cnt[s[i] - 'a'] = (cnt[s[i] - 'a'] + 1) % k;
    for (int64_t j = 0; j < 26; j++) {
      sum[i] += get_cost(cnt[j]);
    }
  }
  if (max_i == -1) {
    cout << -1 << '\n';
    return;
  }
  cnt = vector<int64_t>(26, 0);
  for (int64_t j = 0; j < max_i; j++) {
    cout << s[j];
    cnt[s[j] - 'a'] = (cnt[s[j] - 'a'] + 1) % k;
  }
  cout << extra_ch[max_i];
  cnt[extra_ch[max_i] - 'a'] = (cnt[extra_ch[max_i] - 'a'] + 1) % k;
  string suff = "";
  char ch = 'a';
  for (int64_t j = max_i + 1; j < n; j++) {
    while (ch < 'z' && get_cost(cnt[ch - 'a']) == 0) {
      ch++;
    }
    suff += ch;
    cnt[ch - 'a'] = (cnt[ch - 'a'] + 1) % k;
  }
  cout << string(n - max_i - 1 - (int64_t)suff.size(), 'a') << suff << '\n';
  for (int64_t j = 0; j < 26; j++) {
    assert(cnt[j] % k == 0);
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int64_t t = 1;
  cin >> t;
  for (int64_t tt = 1; tt <= t; tt++) solve(tt);
  return 0;
}
