#include<bits/stdc++.h>
using namespace std;
int n;
map<string, int> mp;
string tmp;
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T;
cin >> T;
while (T--) {
mp.clear();
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> tmp;
mp[tmp]++;
}
int res = 0;
for (auto it : mp) {
res = max(res, it.second);
}
cout << res << endl;
}
}