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.util.concurrent.atomic.LongAccumulator;
import java.util.stream.IntStream;

public class MainJava {
    boolean TEST = true;


    boolean check(char[] s, int k) {
        int[] cnt = new int[26];
        for (char c : s) {
            cnt[c - 'a']++;
        }
        for (int val : cnt) {
            if (val % k != 0) {
                return false;
            }
        }
        return true;
    }

    void solve() throws IOException {
        int n = readInt(), k = readInt();
        char[] s = readString().toCharArray();

        if (n % k != 0) {
            out.print("-1\n");
            return;
        }
        if (check(s, k)) {
            out.print((new String(s)) + "\n");
            return;
        }
        int[] cnt = new int[26];
        for (char c : s) {
            cnt[c - 'a']++;
        }
        int[][] indexes = new int[26][];
        int[] itr = new int[26];
        for (int i = 0; i < 26; i++) {
            indexes[i] = new int[cnt[i]];
        }
        for (int i = 0; i < n; i++) {
            indexes[s[i] - 'a'][itr[s[i] - 'a']++] = i;
        }
        indexes[25] = new int[0];
        ArrayList<String> answers = new ArrayList<>();
        for (int[] arr : indexes) {
            int left = 0;
            int right = arr.length - 1;
            int mid;
            while (left <= right) {
                mid = (left + right) >> 1;
                int midIndex = arr[mid];
                int[] c = new int[26];
                for (int i = 0; i < midIndex; i++) {
                    c[s[i] - 'a']++;
                }
                int[] rem = new int[26];
                for (int i = 0; i < 26; i++) {
                    rem[i] = (k - (c[i] % k)) % k;
                }
                int sum = Arrays.stream(rem).sum();
                int reminderLength = n - midIndex;
                if (reminderLength < sum) {
                    right = mid - 1;
                    continue;
                }

                boolean good = false;

                for (int currentLetter = s[midIndex] - 'a' + 1; currentLetter < 26; currentLetter++) {
                    rem = new int[26];
                    for (int i = 0; i < 26; i++) {
                        rem[i] = (k - (c[i] % k)) % k;
                    }
                    if (rem[currentLetter] == 0) {
                        rem[currentLetter] += k;
                    }
                    sum = Arrays.stream(rem).sum();
                    if (sum > reminderLength) {
                        continue;
                    }
                    while (sum < reminderLength) {
                        rem[0] += k;
                        sum += k;
                    }

                    char[] currentAnswer = new char[n];
                    System.arraycopy(s, 0, currentAnswer, 0, midIndex);
                    currentAnswer[midIndex] = (char) (currentLetter + 'a');
                    rem[currentLetter]--;
                    int j = 0;
                    for (int i = midIndex + 1; i < n; i++) {
                        while (rem[j] == 0) j++;
                        currentAnswer[i] = (char) (j + 'a');
                    }
                    answers.add(new String(currentAnswer));
                    good = true;
                }
                if (good) {
                    left = mid + 1;
                } else {
                    right = mid - 1;
                }
            }
        }


        if (answers.size() == 0) {
            out.print("-1");
        } else {
            out.print(answers.stream().min((s1, s2) -> {
                for (int i = 0; i < n; i++) {
                    if (s1.charAt(i) != s2.charAt(i)) {
                        return Character.compare(s1.charAt(i), s2.charAt(i));
                    }
                }
                return Integer.compare(s1.length(), s2.length());
            }).get() + "\n");
        }
    }

    void solveMain() throws IOException {
        init();
        int t = 1;
        if (TEST) {
            t = readInt();
        }
        while (t-- > 0) {
            solve();
        }
        out.flush();
    }


    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;


    void init() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
    }


    String readLine() throws IOException {
        return in.readLine();
    }

    String delimiter = " ";

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken(delimiter);
    }

    int[] readIntArray(int b) {
        int[] a = new int[b];
        for (int i = 0; i < b; i++) {
            try {
                a[i] = readInt();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a;
    }


    long[] readLongArray(int b) {
        long[] a = new long[b];
        for (int i = 0; i < b; i++) {
            try {
                a[i] = readLong();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a;
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }


    void sortArrayInteger(int[] a) {
        Integer[] arr = new Integer[a.length];
        for (int i = 0; i < a.length; i++) {
            arr[i] = a[i];
        }
        Arrays.sort(arr);
        for (int i = 0; i < a.length; i++) {
            a[i] = arr[i];
        }
    }


    public static void main(String[] args) {
        new MainJava().run();
    }

    void run() {
        try {
            long timeStart = System.currentTimeMillis();

            init();
            solveMain();

            out.close();

            long timeEnd = System.currentTimeMillis();
            System.err.println("Time = " + (timeEnd - timeStart) + " COMPILED");
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

}