#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
int n,m,k,t,ans,maxx;
int x,y,z;
int a[maxn],b[maxn];
map<string,int>mp;
string s;
int main(){
cin>>t;
for(int j=0;j<t;j++){
mp.clear();
maxx=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>s;
mp[s]++;
maxx=max(maxx,mp[s]);
}
cout<<maxx<<endl;
}
}