import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int T = scan.nextInt(); int []ans = new int[T]; Arrays.fill(ans, 0); ArrayList list = new ArrayList(); Map map = new HashMap(); for(int i = 0; i < T; i++) { int N = scan.nextInt(); list.clear(); map.clear(); for(int j = 0; j < N; j++) { int L = scan.nextInt(); if(map.containsKey(L)) { map.put(L, map.get(L) + 1); }else { map.put(L, 1); } } Data []data = new Data[map.size()]; int cnt = 0; for(int key : map.keySet()) { data[cnt] = new Data(key, map.get(key)); cnt ++; } PriorityQueue pq = new PriorityQueue(new Comparator(){ @Override public int compare(Data d1, Data d2) { return d2.getB() - d1.getB(); } }); for(int j = 0; j < data.length; j++) { pq.add(data[j]); } int cnt1 = 0; while (pq.size() >= 3) { cnt1 ++; Data d1 = pq.poll(); Data d2 = pq.poll(); Data d3 = pq.poll(); if(d1.getB() - 1 > 0) { d1.setB(d1.getB() - 1); pq.add(d1); } if(d2.getB() - 1 > 0) { d2.setB(d2.getB() - 1); pq.add(d2); } if(d3.getB() - 1 > 0) { d3.setB(d3.getB() - 1); pq.add(d3); } } ans[i] = cnt1; } scan.close(); for(int i = 0; i < T; i++) { System.out.println(ans[i]); } } } class Data{ private long a; private int b; public Data(long a, int b) { this.a = a; this.b = b; } public long getA() { return a; } public int getB() { return b; } public void setB(int b) { this.b = b; } }