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")
const double pi = std::acos(-1);
using namespace std;
const long long int mod = 1000000000 + 7;
long long int power(long long int x, long long int y, long long int md) {
  long long int res = 1;
  x = x % md;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % md;
    y = y >> 1;
    x = (x * x) % md;
  }
  return res;
}
long long int m_mul(long long int a, long long int b) {
  a = a % mod;
  b = b % mod;
  return (a * b + mod) % mod;
}
long long int m_add(long long int a, long long int b) {
  a = a % mod;
  b = b % mod;
  return (a + b + mod) % mod;
}
long long int spf[(long long int)1e7 + 2] = {0};
struct dsu {
  vector<long long int> parent, rank;
  dsu(long long int n) {
    parent.resize(n + 2);
    rank.resize(n + 2);
  }
  long long int fnd(long long int i) {
    if (parent[i] == i)
      return i;
    else
      return fnd(parent[i]);
  }
  void unite(long long int a, long long int b) {
    if (rank[a] > rank[b])
      parent[b] = a;
    else if (rank[b] > rank[a])
      parent[a] = b;
    else {
      parent[a] = b;
      rank[b]++;
    }
  }
  bool same(long long int a, long long int b) { return fnd(a) == fnd(b); }
};
struct sgtree {
  vector<long long int> arr;
  vector<long long int> tree, lazy;
  sgtree(long long int n, long long int brr[]) {
    arr.resize(n);
    long long int k = 2 * (long long int)powl(2, log2l(n) + 1);
    tree.resize(k);
    lazy.resize(k);
    for (long long int i = 0; i < k; i++) lazy[i] = -1;
    for (long long int i = 0; i < n; i++) arr[i] = brr[i];
  }
  void build(long long int ind, long long int left, long long int right) {
    if (left == right) {
      tree[ind] = arr[left];
      return;
    }
    long long int mid = left + (right - left) / 2;
    build(2 * ind + 1, left, mid);
    build(2 * ind + 2, mid + 1, right);
    tree[ind] = tree[2 * ind + 1] + tree[2 * ind + 2];
  }
  void updateSingle(long long int ind, long long int index, long long int val,
                    long long int left, long long int right) {
    if (left == right && left == index) {
      tree[ind] = val;
      return;
    }
    if (index > right || index < left) return;
    long long int mid = left + (right - left) / 2;
    updateSingle(2 * ind + 1, index, val, left, mid);
    updateSingle(2 * ind + 2, index, val, mid + 1, right);
    tree[ind] = tree[2 * ind + 1] + tree[2 * ind + 2];
  }
  void updateLazy(long long int ind, long long int indexleft,
                  long long int indexright, long long int val,
                  long long int left, long long int right) {
    if (lazy[ind] != -1) {
      tree[ind] = (right - left + 1) * lazy[ind];
      if (left != right) {
        lazy[2 * ind + 1] = lazy[ind];
        lazy[2 * ind + 2] = lazy[ind];
      }
      lazy[ind] = -1;
    }
    if (indexleft > right || indexright < left) return;
    if (indexleft <= left && right <= indexright) {
      tree[ind] = (right - left + 1) * val;
      if (left != right) {
        lazy[2 * ind + 1] = val;
        lazy[2 * ind + 2] = val;
      }
      return;
    }
    long long int mid = left + (right - left) / 2;
    updateLazy(2 * ind + 1, indexleft, indexright, val, left, mid);
    updateLazy(2 * ind + 2, indexleft, indexright, val, mid + 1, right);
    tree[ind] = tree[2 * ind + 1] + tree[2 * ind + 2];
  }
  long long int ans(long long int ind, long long int start, long long int end,
                    long long int left, long long int right) {
    if (lazy[ind] != -1) {
      tree[ind] = (right - left + 1) * lazy[ind];
      if (left != right) {
        lazy[2 * ind + 1] = lazy[ind];
        lazy[2 * ind + 2] = lazy[ind];
      }
      lazy[ind] = -1;
    }
    if (left > end || start > right) return 0;
    if (start <= left && right <= end) return tree[ind];
    long long int mid = left + (right - left) / 2;
    return ans(2 * ind + 1, start, end, left, mid) +
           ans(2 * ind + 2, start, end, mid + 1, right);
  }
};
void siv() {
  spf[1] = 1;
  for (long long int i = 1; i < 1e7 + 2; i++) spf[i] = i;
  for (long long int i = 2; i < 1e7 + 2; i++) spf[i] = 2, i++;
  for (long long int i = 3; i * i < (long long int)1e7 + 2; i++) {
    if (spf[i] == i)
      for (long long int j = i * i; j < (long long int)1e7 + 2; j = j + i)
        if (spf[j] == j) spf[j] = i;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  long long int tc = 1;
  cin >> tc;
  while (tc--) {
    long long int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (n % k) {
      cout << -1 << '\n';
      continue;
    }
    long long int frq[26][s.size()];
    for (long long int i = 0; i < 26; i++) {
      for (long long int j = 0; j < s.size(); j++) frq[i][j] = 0;
    }
    for (long long int i = 0; i < 26; i++) {
      for (long long int j = 0; j < s.size(); j++) {
        if (s[j] - 'a' == i) frq[i][j]++;
      }
    }
    for (long long int i = 0; i < 26; i++) {
      for (long long int j = 1; j < s.size(); j++) {
        frq[i][j] += frq[i][j - 1];
      }
    }
    long long int flkk = 0;
    for (long long int i = s.size() - 1; i > -1; i--) {
      long long int sm = 0;
      for (long long int j = 0; j < 26; j++) {
        sm = sm + (k - frq[j][i] % k) % k;
      }
      long long int pkk = n - (i + 1);
      if (pkk - sm == 0 && i + 1 == n) {
        cout << s << '\n';
        flkk = 1;
        break;
      }
      long long int fll = 0;
      if (sm == pkk) {
        char chh = s[i + 1] + 1;
        if (chh > 'z') continue;
        for (long long int kl = chh - 'a'; kl < 'z' + 1 - 'a'; kl++) {
          if ((k - frq[kl][i] % k) % k) {
            chh = kl + 'a';
            fll = 1;
            break;
          }
        }
        if (fll) {
          for (long long int kl = 0; kl < i + 1; kl++) cout << s[kl];
          for (long long int hh = 0; hh < 1; hh++) {
            cout << chh;
          }
          for (long long int hh = 0; hh < 26; hh++) {
            long long int bb = (k - frq[hh][i] % k) % k;
            char chk = hh + 'a';
            if (chk == chh) {
              for (long long int i = 0; i < bb - 1; i++) {
                cout << chk;
              }
            } else
              for (long long int i = 0; i < bb; i++) {
                cout << chk;
              }
          }
          cout << '\n';
          flkk = 1;
          break;
        }
        if (!fll) continue;
      }
      if (sm < pkk) {
        char chh = s[i + 1] + 1;
        if (chh > 'z') continue;
        for (long long int kl = 0; kl < i + 1; kl++) cout << s[kl];
        string ss = "";
        frq[s[i + 1] - 'a' + 1][i]++;
        sm += ((k - (frq[s[i + 1] - 'a' + 1][i]) % k) % k - sm);
        for (int j = 0; j < 26; j++) {
          if (frq[j][i] % k) {
            for (int z = 0; z < (k - frq[j][i] % k); z++) {
              ss += 'a' + j;
            }
          }
        }
        for (long long int i = 0; i < pkk - 1 - sm; i++) ss += 'a';
        sort(ss.begin(), ss.end());
        s[i + 1]++;
        cout << s[i + 1] << ss << "\n";
        flkk = 1;
        break;
      }
    }
    if (!flkk) {
      cout << (char)(s[0] + 1);
      for (long long int i = 0; i < s.size() - k; i++) cout << 'a';
      for (long long int i = 0; i < k - 1; i++) cout << (char)(s[0] + 1);
      cout << '\n';
    }
  }
  return 0;
}
