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.io.*;
import java.util.*;
public  class KBeautifulStrings{
    static int save,left;
     public static void main(String arg[])throws IOException {
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          StringBuilder sb=new StringBuilder();
          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 s2=br.readLine().trim();
               if(n%k!=0){
               sb.append("-1\n");
               continue;
               }
               else{
               int ar[]=new int[26];
               for(int i=0;i<n;i++)
               ar[s2.charAt(i)-'a']++;
               boolean vi=true;
               int sum=0;
               for(int i=0;i<26;i++)
               {
                    if(ar[i]%k!=0){
                    sum++;
                    break;
                    }
               }
               if(sum==0){
               sb.append(s2+"\n");
               continue;
               }
               vi=false;
               int i;
               for(i=n-1;i>=0;i--)
               {
                    int rem;
                    int ch1=s2.charAt(i)-'a';
                    for(int j=ch1+1;j<26;j++)
                    {
                         int place=0;
                         for(int K=0;K<26;K++)
                         {
                              if(ch1==K)
                              {
                                   rem=ar[K]-1;
                                   rem=(k-(rem)%k)%k;
                                   place+=rem;
                              }
                              else if(j==K)
                              {
                                   rem=ar[K]+1;
                                   rem=(k-(rem)%k)%k;
                                   place+=rem; 
                              }
                              else
                              {
                                    rem=ar[K];
                                   rem=(k-(rem)%k)%k;
                                   place+=rem;
                              }
                         }
                         if(place>n-i-1);
                         else
                         {
                              left=(n-i-1)-place;
                              if(left%k==0)
                              {
                                   vi=true;
                                   save=j;
                                   break;
                              }
                         }
                    }
                    if(vi)break;
                    ar[ch1]--;
               }
               String ans="";
               Arrays.fill(ar,0);
               for(int j=0;j<i;j++)
               {
                    ans+=s2.charAt(j);
                    ar[s2.charAt(j)-'a']++;
               }
               ans+=(char)(save+'a');
               ar[save]++;
               while(left-->0)
               ans+="a";
               for(int j=0;j<26;j++)
               {
                    while(ar[j]%k!=0)
                    {
                         ar[j]++;
                         ans+=(char)(j+'a');
                    }
               }
               sb.append(ans+"\n");
               }
          }
          System.out.println(sb);
     }
     
}