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;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    unordered_map<char, long long> f;
    for (long long i = 0; i < n; i++) {
      f[s[i]]++;
    }
    unordered_map<char, long long> reqF;
    for (auto i : f) {
      if (i.second < k) {
        reqF[i.first] = k;
      } else {
        long long c = i.second / k;
        reqF[i.first] = c * k;
      }
    }
    string out = "";
    if (n % k != 0) {
      cout << -1 << endl;
    } else {
      for (int i = 0; i < s.length(); i++) {
        char curr = s[i];
        while (reqF[curr] > 0) {
          out += curr;
          reqF[curr]--;
          if (out.length() == n) {
            break;
          }
        }
        if (out.length() == n) break;
      }
      sort(out.begin(), out.end(), greater<char>());
      cout << out << endl;
    }
  }
}
