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

//package com.example.activitytest;



/*
Command + D  复制当前行到下一行
Command + Delete  删除当前行
Command + R  替换
Command + Option + L  格式化代码
Control + R  编译
  */

import java.util.*;

import java.io.InputStream;
import java.io.*;

import java.lang.*;


public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Long start = System.currentTimeMillis();
        Map<Integer, Integer> mp = new HashMap<Integer, Integer>();
        int[][] cnt = new int[28][];
        //System.out.println(cnt[0].length());


        int T = in.nextInt();
        while (T-- > 0) {
            int n = in.nextInt(), m = in.nextInt();
            String s = in.readString();

            s = " " + s;
            if (n % m != 0) {
                System.out.println(-1);
            } else {
                for (int j = 1; j <= 26; j++) cnt[j] = new int[n + 1];
                for (int i = 1; i <= n; i++) {
                    for (int j = 1; j <= 26; j++) {
                        cnt[j][i] = cnt[j][i - 1];
                        if (s.charAt(i) - 'a' + 1 == j) {
                            cnt[j][i]++;
                        }
                    }
                }
                int flag = 0, big =0,ok = 0;
                for (int i = 1; i <= 26; i++) {
                    if (cnt[i][n] % m != 0) {
                        ok = 1;
                    }
                }
                if (ok == 1) {
                    for (int i = n; i >= 1; i--) {
                        if (s.charAt(i) == 'z') continue;
                        else {
                            for (int od = 2; od <= 30; od++) {
                                int x = s.charAt(i) - 'a' + od;



                                if(x>=27)break;
                                int need[] = new int[27], sum = 0;
                                //System.out.println(x);
                                for (int j = 1; j <= 26; j++) {
                                    if (j == x)
                                        need[j] = m - ((cnt[j][i] + 1) % m);
                                    else if (j == x - od+1) need[j] = m - ((cnt[j][i] - 1) % m);
                                    else need[j] = m - (cnt[j][i] % m);

                                    if (need[j] == m) need[j] = 0;
                                    sum += need[j];
                                    //if(od==4)System.out.print(need[j]+" ");
                                }

                                //if(od==4)System.out.println(sum);
                                if (sum <= n - i) {

                                    for (int k = 1; k <= i - 1; k++) {
                                        System.out.printf("%c", s.charAt(k));
                                    }
                                    System.out.printf("%c", x + 'a' - 1);
                                    //need[x]--;
                                    for (int j = 1; j <= (n - i - sum); j++) {
                                        System.out.printf("a");
                                    }
                                    for (int j = 1; j <= 26; j++) {
                                        for (int k = 1; k <= need[j]; k++)
                                            System.out.printf("%c", j - 1 + 'a');
                                    }
                                    System.out.println();
                                    flag = 1;
                                    break;
                                }
                            }
                            if(flag==1)break;

                        }

                    }


                } else {
                    for (int i = 1; i <= n; i++) System.out.printf("%c", s.charAt(i));
                    System.out.println("");
                }
            }


        }

        //System.out.println("Time=" + (System.currentTimeMillis() - start) + "ms");


    }

    private static int check(int nh, int nm, Map<Integer, Integer> mp, int h, int m) {
        int a1 = nh / 10, a2 = nh % 10, a3 = nm / 10, a4 = nm % 10;
        int b4 = mp.get(a1), b3 = mp.get(a2), b2 = mp.get(a3), b1 = mp.get(a4);
        if (b1 == -1 || b2 == -1 || b3 == -1 || b4 == -1) return 0;
        if (b1 * 10 + b2 < h && b3 * 10 + b4 < m) return 1;
        return 0;

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }


}

