```go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var T int
fmt.Fscan(reader, &T)
for t := 0; t < T; t++ {
var n, k int
var s string
fmt.Fscan(reader, &n, &k)
fmt.Fscan(reader, &s)
if n%k != 0 {
fmt.Fprintln(writer, -1)
continue
}
cnt := [26]int{}
for i := 0; i < n; i++ {
cnt[s[i]-'a']++
}
need := 0
for i := 0; i < 26; i++ {
need += (k - cnt[i]%k) % k
}
if need == 0 {
fmt.Fprintln(writer, s)
continue
}
found := false
ans := make([]byte, n)
for i := n - 1; i >= 0; i-- {
cidx := s[i] - 'a'
old := (k - cnt[cidx]%k) % k
cnt[cidx]--
new := (k - cnt[cidx]%k) % k
need += new - old
for nc := cidx + 1; nc < 26; nc++ {
old = (k - cnt[nc]%k) % k
cnt[nc]++
new = (k - cnt[nc]%k) % k
need += new - old
if need <= n-i-1 {
copy(ans, s[:i])
ans[i] = byte('a' + nc)
for pos := i + 1; pos < n; pos++ {
for d := 0; d < 26; d++ {
old_d := (k - cnt[d]%k) % k
cnt[d]++
new_d := (k - cnt[d]%k) % k
need += new_d - old_d
if need <= n-pos-1 {
ans[pos] = byte('a' + d)
break
}
cnt[d]--
need -= new_d - old_d
}
}
fmt.Fprintln(writer, string(ans))
found = true
break
}
cnt[nc]--
need -= new - old
}
if found {
break
}
}
if !found {
fmt.Fprintln(writer, -1)
}
}
}
```