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>
const int N = 5e5 + 10, M = 1e7 + 10;
const long long mod = 1e9 + 7;
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long fpow(long long b, long long exp, long long mod) {
  if (exp == 0) return 1;
  long long t = fpow(b, exp / 2, mod);
  if (exp & 1) return t * t % mod * b % mod;
  return t * t % mod;
}
long long divmod(long long i, long long j, long long mod) {
  i %= mod, j %= mod;
  return i * fpow(j, mod - 2, mod) % mod;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t, h, m;
  cin >> t;
  int a, b;
  string s;
  while (t--) {
    cin >> a >> b;
    cin >> s;
    string t = s;
    sort(s.begin(), s.end());
    if (a % b == 0) {
      int len = s.size();
      for (int i = 1; i <= len; i++) cout << s[len - 1];
      cout << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
