#include using namespace std; int main() { int T; cin >> T; while (T--) { int n; cin >> n; map mp; for (int i = 0; i < n; i++) { int a; scanf("%d", &a); mp[a]++; } priority_queue q; for (auto kv : mp) { q.push(kv.second); } int ans = 0; while (q.size() >= 3) { int x = q.top(); q.pop(); int y = q.top(); q.pop(); int z = q.top(); q.pop(); if (x - 1 > 0) q.push(x - 1); if (y - 1 > 0) q.push(y - 1); if (z - 1 > 0) q.push(z - 1); ans++; } cout << ans << endl; } }