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

//stan hu tao
//join nct ridin by first year culture reps
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

public class x1493C
{
    public static void main(String hi[]) throws Exception
    {
        BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(infile.readLine());
        int T = Integer.parseInt(st.nextToken());
        StringBuilder sb = new StringBuilder();
        while(T-->0)
        {
            st = new StringTokenizer(infile.readLine());
            int N = Integer.parseInt(st.nextToken());
            int K = Integer.parseInt(st.nextToken());
            char[] arr = infile.readLine().toCharArray();
            if(N%K != 0)
            {
                sb.append("-1\n");
                continue;
            }
            int[][] psums = new int[N][26];
            for(int c=0; c < 26; c++)
            {
                if(arr[0]-'a' == c)
                    psums[0][c] = 1;
                for(int i=1; i < N; i++)
                {
                    psums[i][c] = psums[i-1][c];
                    if(arr[i]-'a' == c)
                        psums[i][c]++;
                }
            }
            boolean ok = true;
            for(int c=0; c < 26; c++)
                if(psums[N-1][c]%K != 0)
                    ok = false;
            if(ok)
                sb.append(arr).append("\n");
            else
            {
                char[] res = new char[N];
                Arrays.fill(res, '?');
                outer:for(int i=N-1; i >= 0; i--)
                    for(int cc=(arr[i]-'a')+1; cc < 26; cc++)
                    {
                        int[] tot = new int[26];
                        for(int c=0; c < 26; c++)
                        {
                            if(i > 0)
                                tot[c] = psums[i-1][c];
                            if(c == cc)
                                tot[c]++;
                        }
                        int cover = 0;
                        for(int c=0; c < 26; c++)
                        {
                            tot[c] %= K;
                            if(tot[c] > 0)
                            {
                                cover += K-tot[c];
                                tot[c] = K-tot[c];
                            }
                        }
                        if(cover <= N-i-1)
                        {
                            for(int a=0; a < i; a++)
                                res[a] = arr[a];
                            res[i] = (char)(cc+'a');
                            int extra = (N-i-1)-cover;
                            int dex = i+1;
                            while(extra-- > 0)
                                res[dex++] = 'a';
                            for(int c=0; c < 26; c++)
                                while(tot[c]-- > 0)
                                    res[dex++] = (char)(c+'a');
                            break outer;
                        }
                    }
                sb.append(res).append("\n");
            }
        }
        System.out.print(sb);
    }
}