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.*;
import java.text.DecimalFormat;

public class Main {
    static long mod=(long)1e9+7;
    static long mod1=998244353;

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);


        int t= in.nextInt();
        while(t-->0) {

            int n=in.nextInt();
            int k=in.nextInt();
            char[] arr=in.next().toCharArray();
            int[] count=new int[26];
            if(n%k!=0)
                out.println(-1);
            else {
                ArrayList<Character> ll=new ArrayList<>();
                for (char c : arr) {
                    if(count[c-'a']==0) {
                        ll.add(c);
                    }
                    count[c - 'a']++;
                }
                boolean all_divisible=true;

                for(int i:count)
                {
                    if (i % k != 0) {
                        all_divisible = false;
                        break;
                    }
                }
                if(!all_divisible) {
                    if(n==k){
                        for(int i=0;i<n;i++)
                            out.print(ll.get(1));
                        out.println();
                    }else {
                        if (ll.size() == 2) {
                            count[ll.get(0) - 'a'] = n - k;
                            count[ll.get(1) - 'a'] = k;
                            StringBuilder sol=new StringBuilder();
                            for (int i = 0; i < n; i++) {
                                if (arr[i] == ll.get(0)) {
                                    sol.append(arr[i]);
                                    count[ll.get(0) - 'a']--;
                                }
                                if (arr[i] == ll.get(1)) {
                                    sol.append(arr[i]);
                                    count[ll.get(1) - 'a']--;
                                }
                                if (count[ll.get(0) - 'a'] == 0 || count[ll.get(1) - 'a'] == 0)
                                    break;
                            }
                            if(count[ll.get(0)-'a']>0)
                                out.println(-1);
                            else {
                                while (count[ll.get(1) - 'a'] > 0) {
                                    sol.append(ll.get(1));
                                    count[ll.get(1) - 'a']--;
                                }
                                out.print(sol);
                            }
                        }
                        if (ll.size() > 2) {
                            char first = ll.get(0);
                            char second = ll.get(2);
                            out.print(first);
                            out.print(second);
                            for (int i = 0; i < n - k - 1; i++)
                                out.print(first);
                            for (int i = 0; i < k - 1; i++)
                                out.print(second);
                        }
                        out.println();
                    }
                }
                else
                    out.println(arr);
            }
        }
        out.close();
    }




    static final Random random=new Random();

    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    static long gcd(long x, long y){
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = Math.max(x, y);
        b = Math.min(x, y);
        r = b;
        while(a % b != 0){
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
    static long modulo(long a,long b,long c){
        long x=1,y=a%c;
        while(b > 0){
            if(b%2 == 1)
                x=(x*y)%c;
            y = (y*y)%c;
            b = b>>1;
        }
        return  x%c;
    }
    public static void debug(Object... o){
        System.err.println(Arrays.deepToString(o));
    }
    static String printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.00000000000");
        return String.valueOf(ft.format(d));
    }
    static int countBit(long mask){
        int ans=0;
        while(mask!=0){
            mask&=(mask-1);
            ans++;
        }
        return ans;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public int[] readArray(int n)
        {
            int[] arr=new int[n];
            for(int i=0;i<n;i++) arr[i]=nextInt();
            return arr;
        }
    }
}