#include using namespace std; template bool cmin(T &a, U b) { return a > b && (a = b, true); } template bool cmax(T &a, U b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int T; cin >> T; while (T--) { int N; cin >> N; vector L(N); for (int i = 0; i < N; i++) cin >> L.at(i); map MA; for (auto a : L) MA[a]++; priority_queue PQ; for (auto [a, b] : MA) PQ.push(b); int ans = 0; while (PQ.size() >= 3) { int a = PQ.top(); PQ.pop(); int b = PQ.top(); PQ.pop(); int c = PQ.top(); PQ.pop(); a--; if (a) PQ.push(a); b--; if (b) PQ.push(b); c--; if (c) PQ.push(c); ans++; } cout << ans << "\n"; } }