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 gcd(long long a, long long b);
unsigned long long factorial[2000007];
unsigned long long power(unsigned long long x, long long y, int p) {
  unsigned long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
unsigned long long modInverse(unsigned long long n, int p) {
  return power(n, p - 2, p);
}
unsigned long long nc(unsigned long long n, int r, int p) {
  if (r == 0) return 1;
  return (factorial[n] * modInverse(factorial[r], p) % p *
          modInverse(factorial[n - r], p) % p) %
         p;
}
int fa[200005];
int find(int x) {
  if (fa[x] == x) return x;
  fa[x] = find(fa[x]);
  return fa[x];
}
int join(int x, int y) {
  int a = fa[x];
  int b = fa[y];
  if (a == b) return 0;
  fa[a] = b;
  return 1;
}
void deb(int x, string s) { cout << x << " " << s << "\n"; }
int range(int l, int r, vector<int> &b) {
  return upper_bound(b.begin() + 1, b.end(), r) -
         lower_bound(b.begin() + 1, b.end(), l);
}
long long dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
struct element {
  long long p, q, c;
};
bool com(element x, element y) {
  if (x.p == y.p) {
    return x.q < y.q;
  } else {
    return x.p < y.p;
  }
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
bool prime[1000004];
long long spf[1000004];
void SieveOfEratosthenes(int n) {
  for (long long i = 1; i <= 1000003; i++) {
    prime[i] = true;
  }
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void build_spf() {
  for (long long i = 1; i <= 1000003; i++) {
    spf[i] = i;
  }
  for (int p = 2; p * p <= 1000003; p++) {
    if (spf[p] == p) {
      for (int j = 2 * p; j <= 1000003; j += p) {
        spf[j] = p;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  cin >> T;
  while (T--) {
    long long n, k;
    cin >> n >> k;
    long long a[26][n + 1];
    for (int i = 0; i < 26; i++) {
      for (long long j = 1; j <= n + 1; j++) {
        a[i][j - 1] = 0;
      }
    }
    string s;
    cin >> s;
    s = "%" + s;
    for (long long i = 1; i <= n; i++) {
      for (int j = 0; j < 26; j++) {
        a[j][i] = a[j][i - 1];
        a[j][i] %= k;
      }
      a[s[i] - 'a'][i]++;
      a[s[i] - 'a'][i] %= k;
    }
    for (int i = 0; i < 26; i++) {
      for (long long j = 1; j <= n + 1; j++) {
        a[i][j - 1] %= k;
      }
    }
    int f = 1;
    for (long long i = 1; i <= 26; i++) {
      if (a[i - 1][n] != 0) {
        f = 0;
        break;
      }
    }
    if (f == 1) {
      for (long long i = 1; i <= n; i++) {
        cout << s[i];
      }
      cout << "\n";
      continue;
    }
    f = 0;
    for (int i = n; i >= 1; i--) {
      long long x = 0;
      for (long long j = 1; j <= 26; j++) {
        x += ((k - a[j - 1][i - 1])) % k;
      }
      long long y = 0;
      for (int j = s[i] - 'a' + 1; j < 26; j++) {
        y += (k - a[j][i - 1]) % k;
      }
      if ((y > 0 || ((n - i + 1 - x) >= k && (s[i] - 'a' < 25))) &&
          x <= (n - i + 1) && (n - i + 1 - x) % k == 0) {
        f = 1;
        if (y == 0) {
          a[s[i] - 'a' + 1][i - 1] += 1;
          s[i] = 'a' + (s[i] - 'a' + 1);
        } else {
          for (int j = s[i] - 'a' + 1; j < 26; j++) {
            if (a[j][i - 1] > 0) {
              s[i] = 'a' + j;
              a[j][i - 1]--;
            }
          }
        }
        int q = 25;
        int j = n;
        for (j = n; j > i; j--) {
          while (a[q][i - 1] % k == 0 && q >= 0) {
            q--;
          }
          if (q < 0) {
            break;
          } else {
            s[j] = 'a' + q;
            a[q][i - 1]++;
          }
        }
        for (int o = i + 1; o <= j; o++) {
          s[o] = 'a';
        }
        for (long long i = 1; i <= n; i++) {
          cout << s[i];
        }
        cout << "\n";
        break;
      }
    }
    if (f == 0) {
      cout << "-1\n";
    }
  }
  return 0;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
