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.util.*;
import java.util.stream.Collectors;

public class C {

    public static void main(String[] args) {
        Scanner in = new Scanner("4\n" +
                "4 2\n" +
                "abcd\n" +
                "3 1\n" +
                "abc\n" +
                "4 3\n" +
                "aaaa\n" +
                "9 3\n" +
                "abaabaaaa\n");
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int n = in.nextInt();
            int k = in.nextInt();
            String str = in.next();
            if (n % k != 0 || str.matches("^z+$")) {
                System.out.println(-1);
                continue;
            }

            int bit = 1 << 20;
            int prefixLen = 0;
            for (; bit > 0; bit >>= 1) {
                int test = prefixLen | bit;
                if (test <= str.length() && isPossiblePrefix(k, str, str.substring(0, test))) {
                    prefixLen = test;
                }
            }

            if (prefixLen == str.length()) {
                System.out.println(str);
                continue;
            }

            String prefix = str.substring(0, prefixLen);
            for (int c = str.charAt(prefixLen) + 1; c <= 'z'; ++c) {
                String character = Character.toString(c);
                if (isPossiblePrefix(k, str, prefix + character)) {
                    prefix += character;
                    break;
                }
            }
            String ending = reverse(getMaxEnding(k, prefix));
            int charsLeft = str.length() - prefix.length() - ending.length();
            String result = prefix + "a".repeat(charsLeft) + ending;
            System.out.println(result);
        }
    }

    private static String reverse(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    private static boolean isPossiblePrefix(int k, String str, String prefix) {
        String ending = getMaxEnding(k, prefix);
        int charsLeft = str.length() - prefix.length() - ending.length();
        return charsLeft >= 0 && (prefix + "z".repeat(charsLeft) + ending).compareTo(str) >= 0;
    }

    private static String getMaxEnding(int k, String prefix) {
        TreeMap<Character, Integer> counts = new TreeMap<>();
        for (char c : prefix.toCharArray()) {
            counts.put(c, 1 + counts.getOrDefault(c, 0));
        }
        return counts.descendingMap().entrySet().stream()
                .map(entry -> entry.getKey().toString().repeat((k - (entry.getValue() % k)) % k))
                .collect(Collectors.joining());
    }
}
