package jp.fedom.challange.yuki.l2.q120; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int i = 0; i < T; i++) { int N = sc.nextInt(); int[] L = new int[N]; for (int j = 0; j < N; i++) { L[j] = sc.nextInt(); } System.out.println(solve(N, L)); } sc.close(); } public static int solve(int N, int[] L) { int c = 0; while (L.length - c >= 3) { List k = new ArrayList<>(); for (int i = 0; i < L.length; i++) { if (L[i] == -1) { continue; } if (k.contains(L[i])) { continue; } k.add(L[i]); L[i] = -1; if (k.size() == 3) { break; } } if (k.size() == 3) { c += 3; } else { break; } } return c / 3; } }