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;
vector<long long int> shortestpath(
    vector<pair<long long int, long long int>> adj[], long long int V,
    long long int src) {
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      pq;
  vector<long long int> dist(V, 9e+18);
  pq.push(make_pair(0, src));
  dist[src] = 0;
  while (!pq.empty()) {
    long long int u = pq.top().second;
    pq.pop();
    for (auto x : adj[u]) {
      long long int v = x.first;
      long long int weight = x.second;
      if (dist[v] > dist[u] + weight) {
        dist[v] = dist[u] + weight;
        pq.push(make_pair(dist[v], v));
      }
    }
  }
  return dist;
}
struct Trie {
  struct Trie *children[26];
  bool endOfWord;
};
struct Trie *getnode(void) {
  struct Trie *pnode = new Trie;
  pnode->endOfWord = false;
  for (long long int i = 0; i < 26; i++) {
    pnode->children[i] = NULL;
  }
  return pnode;
}
void insertstring(struct Trie *root, string s) {
  struct Trie *p = root;
  long long int n = s.length();
  for (long long int i = 0; i < n; i++) {
    long long int k = s[i] - 'a';
    if (!p->children[k]) {
      p->children[k] = getnode();
    }
    p = p->children[k];
  }
  p->endOfWord = true;
}
bool searchstring(struct Trie *root, string s) {
  struct Trie *p = root;
  long long int n = s.length();
  for (long long int i = 0; i < n; i++) {
    long long int k = s[i] - 'a';
    if (p->children[k] == NULL) {
      return false;
    }
    p = p->children[k];
  }
  return (p->endOfWord && p != NULL);
}
void buildsegment(long long int arr[], long long int tree[], long long int n) {
  for (long long int i = 0; i < n; i++) tree[n + i] = arr[i];
  for (long long int i = n - 1; i > 0; --i)
    tree[i] = tree[i << 1] + tree[i << 1 | 1];
}
void updatesegment(long long int p, long long int value, long long int tree[],
                   long long int n) {
  tree[p + n] = value;
  p = p + n;
  for (long long int i = p; i > 1; i >>= 1)
    tree[i >> 1] = tree[i] + tree[i ^ 1];
}
long long int querysegment(long long int l, long long int r,
                           long long int tree[], long long int n) {
  long long int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += tree[l++];
    if (r & 1) res += tree[--r];
  }
  return res;
}
long long int findpar(long long int numb, long long int par[]) {
  if (par[numb] == numb)
    return numb;
  else
    return par[numb] = findpar(par[numb], par);
}
void setpar(long long int u1, long long int v1, long long int par[]) {
  long long int s1 = findpar(v1, par);
  long long int s2 = findpar(u1, par);
  if (s1 < s2) {
    par[s2] = s1;
  } else {
    par[s1] = s2;
  }
}
long long int extended_GCD(long long int a, long long int b, long long int &x,
                           long long int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long int modinv(long long int a, long long int mod = 1000000007) {
  long long int x, y;
  extended_GCD(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
long long int power(long long int a, long long int b,
                    long long int m = 1000000007) {
  a %= m;
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
vector<long long int> nge(long long int arr[], long long int n) {
  stack<long long int> s;
  vector<long long int> ans(n, -1);
  s.push(0);
  for (long long int i = 1; i < n; i++) {
    if (s.empty()) {
      s.push(i);
      continue;
    }
    while (s.empty() == false && arr[s.top()] < arr[i]) {
      ans[s.top()] = i;
      s.pop();
    }
    s.push(i);
  }
  return ans;
}
string sumstring(string str1, string str2) {
  if (str1.length() > str2.length()) {
    string ext = str1;
    str1 = str2;
    str2 = ext;
  }
  string str = "";
  long long int n1 = str1.length(), n2 = str2.length();
  reverse(str1.begin(), str1.end());
  reverse(str2.begin(), str2.end());
  long long int carry = 0;
  for (long long int i = 0; i < n1; i++) {
    long long int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (long long int i = n1; i < n2; i++) {
    long long int sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
void swap(long long int &a, long long int &b) {
  long long int temp = a;
  a = b;
  b = temp;
}
void dfsb(vector<vector<long long int>> &adj, long long int curind,
          long long int p) {
  for (long long int i = 0; i < adj[curind].size(); i++) {
    if (adj[curind][i] != p) {
      dfsb(adj, adj[curind][i], curind);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1, n, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    string s;
    cin >> s;
    if (n % k != 0) {
      cout << -1 << "\n";
      continue;
    }
    vector<long long int> v(26, 0);
    vector<long long int> st(26, -1);
    long long int counter = 0;
    long long int fill = -1;
    for (long long int i = 0; i < n; i++) {
      if (v[s[i] - 'a'] != 0) {
        if (v[s[i] - 'a'] == k - 1) {
          v[s[i] - 'a'] = 0;
        } else {
          v[s[i] - 'a']++;
        }
      } else if (v[s[i] - 'a'] == 0) {
        if (counter + i < n) {
          st[s[i] - 'a'] = i;
          v[s[i] - 'a']++;
          if (v[s[i] - 'a'] == k) {
            v[s[i] - 'a'] = 0;
          }
        } else {
          for (char i1 = 'z'; i1 >= 'a'; i1--) {
            if (v[i1 - 'a'] != 0 && i1 > s[i]) {
              s[i] = i1;
              fill = i + 1;
              if (v[i1 - 'a'] % k == k - 1) {
                v[i1 - 'a'] = 0;
              } else
                v[i1 - 'a']++;
              break;
            } else if (i1 <= s[i]) {
              break;
            }
          }
          if (fill == -1) {
            long long int mini = -1;
            for (long long int i5 = 0; i5 <= 25; i5++) {
              if (st[i5] != -1) {
                mini = max(mini, st[i5]);
              }
            }
            long long int req;
            for (long long int i2 = 25; i2 >= 0; i2--) {
              if (st[i2] == mini) {
                req = i2;
                break;
              }
            }
            long long int non = v[req];
            v[req + 1] = v[req];
            v[req] = 0;
            char con = char('a' + req);
            for (long long int i3 = i; i3 >= 0; i3--) {
              if (non == 0) break;
              if (s[i3] == con) {
                s[i3] = char(con + 1);
                non--;
              }
            }
            fill = i;
            break;
          }
        }
      }
      if (fill != -1) break;
      counter = 0;
      for (long long int i = 0; i < 26; i++) {
        if (v[i] % k == 0) continue;
        counter += (k - (v[i] % k));
      }
    }
    if (fill == -1) {
      cout << s << "\n";
      continue;
    }
    for (long long int i = 0; i < fill; i++) {
      cout << s[i];
    }
    for (char i = 'a'; i <= 'z'; i++) {
      if (v[i - 'a'] == 0) continue;
      for (long long int i2 = v[i - 'a']; i2 < k; i2++) {
        cout << i;
      }
    }
    cout << "\n";
  }
  return 0;
}
