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.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Reader in = new Reader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        int t = in.nextInt();
        for (int cas = 0; cas < t; cas++) {
            run(in, out);
        }

        out.flush();
        in.close();
        out.close();
    }

    private static int m;
    private static int n;
    private static char[] s;
    private static int[][] count;

    private static void run(Reader in, PrintWriter out) throws IOException {
        n = in.nextInt();
        m = in.nextInt();
        s = in.nextLine().toCharArray();

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

        buildCount();
        if (isNoChange()) {
            out.println(new String(s));
            return;
        }

        int changeAtMe = getChangePos();

        if (changeAtMe == 0) {
            char first = (char) (s[0] + 1);
            for (int i = 0; i < n; i++) s[i] = 'a';
            s[0] = first;
            for (int i = n - m + 1; i < n; i++) {
                s[i] = first;
            }
        } else {
            int currentChar = s[changeAtMe] - 'a';
            int nextChar = currentChar + 1;
            for (int i = nextChar; i < 26; i++) {
                if (getNeed(changeAtMe - 1, i) != 0) {
                    nextChar = i;
                }
            }
            count[changeAtMe][currentChar]--;
            count[changeAtMe][nextChar]++;
            s[changeAtMe] = (char) (nextChar + 'a');
            int fixPos = 0;
            for (int i = changeAtMe + 1; i < n; i++) {
                while (fixPos < 26 && getNeed(changeAtMe, fixPos) == 0) {
                    fixPos++;
                }

                if (fixPos == 26) {
                    s[i] = 'a';
                } else {
                    count[changeAtMe][fixPos]++;
                    s[i] = (char) (fixPos + 'a');
                }
            }
        }

        out.println(new String(s));
    }

    private static int getChangePos() {
        for (int i = n - 1; i >= 1; i--) {
            int now = s[i] - 'a';
            if (now == 25) continue;

            int totalNeed = 0;
            boolean useful = false;
            for (int j = 0; j < 26; j++) {
                int need = getNeed(i - 1, j);
                totalNeed += need;
                if (need != 0 && j > now) {
                    useful = true;
                }
            }
            if (useful) totalNeed -= 1;
            else totalNeed += m - 1;

            int afterMe = n - 1 - i;
            if (totalNeed <= afterMe) {
                return i;
            }
        }
        return 0;
    }

    private static boolean isNoChange() {
        for (int i = 0; i < 26; i++) {
            if (getNeed(n - 1, i) != 0) {
                return false;
            }
        }
        return true;
    }

    private static void buildCount() {
        count = new int[n][26];
        for (int i = 0; i < n; i++) {
            int now = s[i] - 'a';
            if (i == 0) {
                count[i][now] = 1;
            } else {
                System.arraycopy(count[i - 1], 0, count[i], 0, 26);
                count[i][now]++;
            }
        }
    }

    private static int getNeed(int pos, int c) {
        int remain = count[pos][c] % m;
        if (remain != 0) {
            return m - remain;
        } else {
            return 0;
        }
    }

    static class Reader {
        BufferedReader reader;
        StringTokenizer st;

        Reader(InputStreamReader stream) {
            reader = new BufferedReader(stream);
            st = null;
        }

        void close() throws IOException {
            reader.close();
        }

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

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

        String nextLine() throws IOException {
            return reader.readLine();
        }

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

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

    }
}