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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class problemC {
    static class Solution {
        void solve() throws Exception {
            int n = fs.nextInt(), k = fs.nextInt();
            char[] S = fs.next().toCharArray();

            if (n % k != 0) {
                out.println(-1); return;
            }

            int[] s = new int[n];
            for (int i = 0; i < n ; i ++ ) s[i] = (int)(S[i]-'a');

            int[] freq = new int[26];
            for (int c : s) freq[c] ++;

            boolean already = true;
            for (int x : freq) if (x % k != 0) { already = false; break ; }
            if (already) { out.println(new String(S)); return ; }

            int size = n / k;
            if (first(s, n, size, k)) return;

            // debug("going second");
            inc(s, n, size, k);
        }

        void inc(int[] s, int n, int size, int k) {
            int[] pattern = new int[size];

            int ind = size-1;
            for (; ind >= 0 && s[ind] == 25; ind--) pattern[ind] = s[ind];
            // ind has to be greater than 0 as all are not 'z'.
            pattern[ind] = s[ind]+1;
            ind --;
            for (; ind >= 0 ; ind --) pattern[ind] = s[ind];

            print(pattern);
            Arrays.sort(pattern);
            for (int i = 1 ; i < k ; i ++ ) print(pattern);
            out.println();
        }

        boolean first(int[] s, int n, int size, int k) throws Exception {
            int[] freq = new int[26];
            int[] ans = new int[n];

            // try the first set.
            boolean smallest = false;
            for (int start = 0 ; start < n ; start += size) {
                for (int i = 0 ; i < size ; i ++ ) freq[s[i]]++;
                for (int j = 0 ; j < size ; j ++ ) {
                    int x = s[j+start];
                    if (smallest) {
                        x = 0;
                        while (x < 26 && freq[x] == 0) x ++ ;
                        if (x == 26) return false;
                        ans[j+start] = x;
                        freq[x] --;
                    } else if (freq[x] > 0 ) {
                        ans[j+start] = x;
                        freq[x] --;
                    } else {
                        while (x < 26 && freq[x] == 0) x ++ ;
                        if (x == 26) return false;
                        ans[j+start] = x;
                        freq[x]--;
                        smallest = true;
                    }

                }
                for (int x : freq) if (x != 0 ) throw new Exception("freq should be 0");
            }

            print(ans); out.println();
            return true;
        }

        void print(int[] a) {
            for (int x : a) out.print((char)(x + 'a'));
        }
    }

    public static void main(String[] args) throws Exception {
        int T = 1;
        T = fs.nextInt();
        Solution solution = new Solution();
        for (int t = 0; t < T; t++) solution.solve();
        out.close();
    }

    static void debug(Object... O) {
        System.err.println("DEBUG: " + Arrays.deepToString(O));
    }

    private static FastScanner fs = new FastScanner();
    private static PrintWriter out = new PrintWriter(System.out);

    static class FastScanner { // Thanks SecondThread.
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }

        ArrayList<Integer> readArrayList(int n) {
            ArrayList<Integer> a = new ArrayList<>(n);
            for (int i = 0 ; i < n; i ++ ) a.add(fs.nextInt());
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextString() {
            return next();
        }
    }
}
