package main
import (
"bufio"
"io"
"os"
"strconv"
)
func main() {
buf, _ := io.ReadAll(os.Stdin)
var pos int
readInt := func() int {
for pos < len(buf) && (buf[pos] < '0' || buf[pos] > '9') {
pos++
}
if pos >= len(buf) {
return 0
}
res := 0
for pos < len(buf) && buf[pos] >= '0' && buf[pos] <= '9' {
res = res*10 + int(buf[pos]-'0')
pos++
}
return res
}
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
t := readInt()
for i := 0; i < t; i++ {
n := readInt()
k := readInt()
a := make([]int, n)
for j := 0; j < n; j++ {
a[j] = readInt()
}
seen := make([]int, n+2)
marker := 0
check := func(x int) bool {
if x == 0 {
return true
}
count := 0
found := 0
marker++
for j := 0; j < n; j++ {
v := a[j]
if v < x {
if seen[v] != marker {
seen[v] = marker
found++
if found == x {
count++
if count == k {
return true
}
found = 0
marker++
}
}
}
}
return false
}
low, high := 0, n/k
ans := 0
for low <= high {
mid := low + (high-low)/2
if check(mid) {
ans = mid
low = mid + 1
} else {
high = mid - 1
}
}
out.WriteString(strconv.Itoa(ans) + "\n")
}
}