package main
import (
"bufio"
"bytes"
"io"
"os"
"strconv"
)
func main() {
data, _ := io.ReadAll(os.Stdin)
idx := 0
nextInt := func() int {
for idx < len(data) && data[idx] <= ' ' {
idx++
}
sign := 1
if idx < len(data) && data[idx] == '-' {
sign = -1
idx++
}
val := 0
for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
val = val*10 + int(data[idx]-'0')
idx++
}
return sign * val
}
t := nextInt()
var out bytes.Buffer
const inf = int(1e9)
for ; t > 0; t-- {
n := nextInt()
k := nextInt()
a := make([]int, n+1)
for i := 1; i <= n; i++ {
a[i] = nextInt()
}
dp := make([]int, n+1)
ans := inf
for i := 1; i <= n; i++ {
if a[i] > i {
continue
}
dp[i] = 1
ci := i - a[i]
for j := 1; j < i; j++ {
if dp[j] > 0 && a[j] < a[i] && j-a[j] <= ci {
if dp[j]+1 > dp[i] {
dp[i] = dp[j] + 1
}
}
}
if dp[i] >= k && ci < ans {
ans = ci
}
}
if ans == inf {
out.WriteString("-1\n")
} else {
out.WriteString(strconv.Itoa(ans))
out.WriteByte('\n')
}
}
w := bufio.NewWriter(os.Stdout)
w.Write(out.Bytes())
w.Flush()
}