import itertools



N = int(eval(input()))



all_list = list(itertools.product([0,1], repeat=N))



xy_list =[]



for i in range(N):

    for j in range(int(eval(input()))):

        x, y = list(map(int, input().split()))

        xy_list.append((i+1,x,y))



#print(xy_list)



num_ok = 0

for i in all_list:

    #どの人の証言なのか

    flag = True



    for j in xy_list:

        if i[j[0]-1] == 1:

            if i[j[1]-1] != j[2]:

                flag = False        

    if flag == True:

        if num_ok < i.count(1):

            num_ok = i.count(1)





print(num_ok)



import itertools



N = int(eval(input()))



all_list = list(itertools.product([0,1], repeat=N))



xy_list =[]



for i in range(N):

    for j in range(int(eval(input()))):

        x, y = list(map(int, input().split()))

        xy_list.append((i+1,x,y))



#print(xy_list)



num_ok = 0

for i in all_list:

    #どの人の証言なのか

    flag = True



    for j in xy_list:

        if i[j[0]-1] == 1:

            if i[j[1]-1] != j[2]:

                flag = False        

                break



    if flag == True:

        if num_ok < i.count(1):

            num_ok = i.count(1)





print(num_ok)





            

import itertools

N = int(eval(input()))
all_list = list(itertools.product([0, 1], repeat=N))
xy_list = []
for i in range(N):
    for j in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        xy_list.append((i + 1, x, y))
# print(xy_list)
num_ok = 0
for i in all_list:
    # どの人の証言なのか
    flag = True
    for j in xy_list:
        if i[j[0] - 1] == 1:
            if i[j[1] - 1] != j[2]:
                flag = False
    if flag == True:
        if num_ok < i.count(1):
            num_ok = i.count(1)
print(num_ok)

import itertools

N = int(eval(input()))
all_list = list(itertools.product([0, 1], repeat=N))
xy_list = []
for i in range(N):
    for j in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        xy_list.append((i + 1, x, y))
# print(xy_list)
num_ok = 0
for i in all_list:
    # どの人の証言なのか
    flag = True
    for j in xy_list:
        if i[j[0] - 1] == 1:
            if i[j[1] - 1] != j[2]:
                flag = False
                break
    if flag == True:
        if num_ok < i.count(1):
            num_ok = i.count(1)
print(num_ok)

+                break