use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let t: usize = itr.next().unwrap().parse().unwrap(); let mut out = Vec::new(); for _ in 0..t { let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut map = std::collections::HashMap::new(); let mut bh = std::collections::BinaryHeap::new(); for i in 0..n { let p = map.entry(a[i]).or_insert(0); *p += 1; } for (&_k, &v) in map.iter() { bh.push(v); } let mut ans = 0; while bh.len() > 2 { let a = bh.pop().unwrap(); let b = bh.pop().unwrap(); let c = bh.pop().unwrap(); if a > 0 { bh.push(a - 1); } if b > 0 { bh.push(b - 1); } if c > 0 { bh.push(c - 1); } if a > 0 && b > 0 && c > 0 { ans += 1; } } writeln!(out, "{}", ans).ok(); } stdout().write_all(&out).unwrap(); }