import org.checkerframework.checker.units.qual.A;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
/**
* className:test4
* Package:PACKAGE_NAME
*
* @Author:swx
* @Create2024/1/1114:52
* @version:1.0
*/
public class test4 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N1 = scanner.nextInt(); // 测试用例的个数;
for (int i=0; i<N1; i++) {
HashMap<String, Integer> map = new HashMap<>();
HashMap<String, Integer> temp =new HashMap<>();
int max=1 ;
int N2 = scanner.nextInt(); // 帧的数量;
for (int j=0; j<N2; j++) {
//清空辅助map
temp.clear();
int N3 = scanner.nextInt(); // 一帧特征的数量
for (int k=0; k<N3; k++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
String Key = String.valueOf(a) + "_" + String.valueOf(b);
temp.put(Key, map.getOrDefault(Key,0)+1);
max = Math.max(temp.get(Key), max);
}
map.clear();
map.putAll(temp);
}
if (max <= 1) {
System.out.println(1);
}else {
System.out.println(max);
}
}
}
}