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.util.Arrays;
import java.util.TreeMap;

public class Div2 {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String[] inputString = reader.readLine().split(" ");
    StringBuilder sb = new StringBuilder();
    Div2 div2 = new Div2();
    int T = Integer.parseInt(inputString[0]);
    while (T-- > 0) {
      inputString = reader.readLine().split(" ");
      int n = Integer.parseInt(inputString[0]);
      int k = Integer.parseInt(inputString[1]);
      String s = reader.readLine();
      if (s.length() % k != 0) {
        sb.append("-1").append("\n");
        continue;
      }
      char[] sub = s.substring(0, n / k).toCharArray();
      String valid = div2.isValid(s, sub, k);
      if (valid != null) {
        sb.append(valid).append("\n");
        continue;
      }
      for (int i = sub.length - 1; i >= 0; i--) {
        if (sub[i] == 'z') {
          continue;
        }
        sub[i] = (char) (sub[i] + 1);
        for (int j = i + 1; j < sub.length; j++) {
          sub[j] = 'a';
        }
        sb.append(new String(sub));
        Arrays.sort(sub);
        for (char c : sub) {
          for (int j = 0; j < k - 1; j++) {
            sb.append(c);
          }
        }
        sb.append("\n");
        break;
      }
    }
    System.out.println(sb.toString());
  }

  private String isValid(String s, char[] sub, int k) {
    TreeMap<Character, Integer> treeMap = new TreeMap<>();
    StringBuilder sb = new StringBuilder(new String(sub));
    for (char c : sub) {
      treeMap.put(c, treeMap.getOrDefault(c, 0) + k - 1);
    }
    for (int i = k; i < s.length(); i++) {
      Character c = treeMap.ceilingKey(s.charAt(i));
      if (c == null) {
        return null;
      }
      sb.append(c);
      Integer count = treeMap.get(c);
      if (count == 1) {
        treeMap.remove(c);
      } else {
        treeMap.put(c, count - 1);
      }
    }
    return sb.toString();
  }
}