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

for _ in range(int(input())) :
     arr=list(map(int,input().split()))
     x=input()
     w=dict()
     b=''
     if arr[0]%arr[1]!=0 :
          print(-1)
     else  :
          for i in x :
               w[i]=w.get(i,0)+1
          ch=sorted(list(w.keys()),reverse=True)
          k=0
          for j in ch:
               while k < arr[1] and len(b) < arr[0] :
                    b=b+j
          print(b)
                    
               
          
     
