package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) t := nextInt() for p := 0; p < t; p++ { n, c := nextInt(), 0 m := make(map[int]int) for i := 0; i < n; i++ { m[nextInt()]++ } for { kd := make([]int, 0, 3) for i := 0; i < 3; i++ { s, max := 0, 0 for k, v := range m { found := false for _, v2 := range kd { if k == v2 { found = true break } } if v > max && !found { max, s = v, k } } if s == 0 { break } kd = append(kd, s) m[s]-- } if len(kd) < 3 { break } c++ } fmt.Println(c) } } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i } func nextInt64() int64 { i, _ := strconv.ParseInt(nextLine(), 10, 64) return i } func comb(a []int, r int, fn func([]int)) { if r > len(a) || r < 1 { return } var f func([]int, int, int) f = func(ret []int, last, c int) { if c == 0 { fn(ret) return } c-- for i, v := range a[last : len(a)-c] { ret[r-c-1] = v f(ret, i+last+1, c) } } ret := make([]int, r) f(ret, 0, r) }