时间复杂度:O(NML)
空间复杂度:O(L)
维护一个buff字典

buff = {}
maxlen = 0
n = int(input())
for _ in range(n):
    m = int(input())
    for _ in range(m):
        line = input().split()
        newbuff = {}
        for j in range(1,int(line[0])+1):
            i = 2*(j-1)+1
            #print(line[i]+line[i+1])
            if line[i]+line[i+1] in buff:
                newbuff[line[i]+line[i+1]] = buff[line[i]+line[i+1]]+1
            else:
                newbuff[line[i]+line[i+1]] = 1
            maxlen = max(maxlen,newbuff[line[i]+line[i+1]])
        buff = {}
        buff = newbuff
        #print(m,maxlen)

print(maxlen)