#include using namespace std; signed main(){ int T; cin >> T; for( int kase = 0; kase < T; ++kase ){ int N; cin >> N; vector< int > L( N ); for( int i = 0; i < N; ++i ) cin >> L[ i ]; priority_queue< pair< int, int > > pq; map< int, int > lcnt; for( int i = 0; i < N; ++i ) ++lcnt[ L[ i ] ]; for( auto it = lcnt.begin(); it != lcnt.end(); ++it ) pq.emplace( it->second, it->first ); int ans = 0; while( pq.size() >= 3 ){ auto a = pq.top(); pq.pop(); auto b = pq.top(); pq.pop(); auto c = pq.top(); pq.pop(); ++ans; if( a.first - 1 > 0 ) pq.emplace( a.first - 1, a.second ); if( b.first - 1 > 0 ) pq.emplace( b.first - 1, b.second ); if( c.first - 1 > 0 ) pq.emplace( c.first - 1, c.second ); } cout << ans << endl; } return 0; }