#include <iostream>
#include<cstring>
#include<cstdio>
#include<map>
using namespace std;
const int N = 100000+5;
typedef pair<int,int> P;
map<P,int> mp[N];
int main()
{
int T; scanf("%d",&T);
while(T--)
{
int mx= 0;
int n;
scanf("%d",&n);
for(int i = 1; i <= n; i++)
{
mp[i].clear();
int q;
scanf("%d",&q);
for(int j = 1; j <= q; j++)
{
int x,y; scanf("%d %d",&x,&y);
mp[i][P(x,y)] = mp[i-1][P(x,y)] + 1;
if(mx < mp[i][P(x,y)])
mx= mp[i][P(x,y)];
}
}
printf("%d\n",mx);
}
return 0;
}