import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int a = 0; a < t; a++) { int n = sc.nextInt(); HashMap map = new HashMap<>(); for (int i = 0; i < n; i++) { int x = sc.nextInt(); map.put(x, map.getOrDefault(x, 0) + 1); } PriorityQueue queue = new PriorityQueue<>(); for (int x : map.values()) { queue.add(-x); } int count = 0; while (queue.size() >= 3) { count++; int[] arr = new int[3]; for (int i = 0; i < 3; i++) { arr[i] = queue.poll() + 1; } for (int x : arr) { if (x < 0) { queue.add(x); } } } sb.append(count).append("\n"); } System.out.print(sb); } }