#include #include #include #include #include using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int n; map tbl; scanf("%d",&n); for(int i=0;i Q; for(map::iterator it=tbl.begin();it!=tbl.end();++it){ Q.push((*it).second); } int ans = 0; while(true){ if(Q.size()<3) break; int a = Q.top(); Q.pop(); int b = Q.top(); Q.pop(); int c = Q.top(); Q.pop(); ++ans; if(a>1) Q.push(a-1); if(b>1) Q.push(b-1); if(c>1) Q.push(c-1); } printf("%d\n",ans); } return 0; }