import java.util.ArrayList; import java.util.Arrays; 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(); for(int i = 0; i < T; i++) { int N = scan.nextInt(); list.clear(); for(int j = 0; j < N; j++) { list.add(scan.nextInt()); } while(list.size() >= 3) { int t1, t2 = 0, t3 = 0; t1 = list.get(0); list.remove(0); for(int j = 0; j < list.size(); j++) { t2 = list.get(j); if(t1 != t2) { list.remove(j); break; } } for(int j = 0; j < list.size(); j++) { t3 = list.get(j); if(t3 != t2 && t3 != t1) { list.remove(j); ans[i]++; break; } } } } scan.close(); for(int i = 0; i < T; i++) { System.out.println(ans[i]); } } }