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.*;

public class Rough{

    public static boolean beautiful(String s,int k)
    {
        boolean b=true;
        int n=s.length();
        int[] arr=new int[n];
        for(int j=0;j<n;j++)
        {
            arr[j]=0;
        }
        for(int j=0;j<n;j++)
        {
            arr[s.charAt(j)-97]++;
        }
        for(int j=0;j<n;j++)
        {
            if(arr[j]%k!=0)
            {
                b=false;
                break;
            }
        }
        return b;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int T=sc.nextInt();
        for(int i=0;i<T;i++)
        {
            // a b c d
           int n=sc.nextInt();
           int k=sc.nextInt();
           String s=sc.next();
           char[] a=new char[n];
           if(n%k!=0)
           {
               System.out.println(-1);
           }
           else
           {
               boolean b=beautiful(s,k);
               if(b)
                   System.out.println(s);
               else
               {
                    
               }
           }
        }
    }
}