#include #include #include #include #include using namespace std; int main() { int T; cin >> T; while (T--) { int n; cin >> n; map cnt; while (n--) { int l; cin >> l; cnt[l]++; } priority_queue pq; for (auto &p: cnt) pq.emplace(p.second); 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(); ans++; if (a - 1) pq.emplace(a - 1); if (b - 1) pq.emplace(b - 1); if (c - 1) pq.emplace(c - 1); } cout << ans << endl; } return 0; }