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

import java.util.*;
import java.io.*;
 
public class Main {
    
    public static void main(String[] args) throws NumberFormatException,IOException{
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        while(t--!=0){
            String[] s = br.readLine().split(" ");
            int n = Integer.parseInt(s[0]);
            int k = Integer.parseInt(s[1]);
            
            String s1 = br.readLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int i=0;i<n;i++){
                list.add(s1.charAt(i));
            }
            Collections.sort(list,Collections.reverseOrder());
            
            String ans = "";
            
            if(n%k!=0){
                System.out.println(-1);
                continue;
            }
                
            int idx=0;
            for(int i=0;i<n;i+=k){
                int temp = k;
                while(temp-- !=0){
                    ans = ans + list.get(idx);
                }
                idx++;
            }
            System.out.println(ans);
        }
    }
}