N = int(eval(input()))

testimony = [[] for _ in range(N)]

ans = 0

for n in range(N):

    A = int(eval(input()))

    for _ in range(A):

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

        testimony[n].append([x-1,y]) # 人のナンバリングを0startにする

# print(testimony)

for bit in range(2**N):

#     print("bit",bit)

    honest_cnt = 0

    for j in range(N):

#         print("j",j)

        if (bit>>j) & 1:

            honest_cnt += 1

            for t in testimony[j]:

                if (bit>>t[0])&1 != t[1]:

#                     print("break")

                    break

            else:

#                 print("continue")

                continue

#             print("break")

            break

    else:

#         print("new_ans")

        ans = max(ans,honest_cnt)

print(ans)
import itertools

N = int(eval(input()))

testimony = []

for n in range(N):

    A = int(eval(input()))

    testimony.append([list(map(int,input().split())) for _ in range(A)])



ans = 0

for bit in itertools.product([0,1],repeat = N):

    for n in range(N):

        if bit[n]:

            for t in testimony[n]:

                if bit[t[0]-1] != t[1]:

                    break

            else:

                continue

            break

    else:

        ans = max(ans,sum(bit))

print(ans)
N = int(eval(input()))
testimony = [[] for _ in range(N)]
ans = 0
for n in range(N):
    A = int(eval(input()))
    for _ in range(A):
        x, y = list(map(int, input().split()))
        testimony[n].append([x - 1, y])  # 人のナンバリングを0startにする
# print(testimony)
for bit in range(2**N):
    #     print("bit",bit)
    honest_cnt = 0
    for j in range(N):
        #         print("j",j)
        if (bit >> j) & 1:
            honest_cnt += 1
            for t in testimony[j]:
                if (bit >> t[0]) & 1 != t[1]:
                    #                     print("break")
                    break
            else:
                #                 print("continue")
                continue
            #             print("break")
            break
    else:
        #         print("new_ans")
        ans = max(ans, honest_cnt)
print(ans)

import itertools

N = int(eval(input()))
testimony = []
for n in range(N):
    A = int(eval(input()))
    testimony.append([list(map(int, input().split())) for _ in range(A)])
ans = 0
for bit in itertools.product([0, 1], repeat=N):
    for n in range(N):
        if bit[n]:
            for t in testimony[n]:
                if bit[t[0] - 1] != t[1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, sum(bit))
print(ans)

+import itertools + -testimony = [[] for _ in range(N)] -ans = 0 +testimony = [] -    for _ in range(A): -        x, y = list(map(int, input().split())) -        testimony[n].append([x - 1, y])  # 人のナンバリングを0startにする -# print(testimony) -for bit in range(2**N): -    #     print("bit",bit) -    honest_cnt = 0 -    for j in range(N): -        #         print("j",j) -        if (bit >> j) & 1: -            honest_cnt += 1 -            for t in testimony[j]: -                if (bit >> t[0]) & 1 != t[1]: -                    #                     print("break") +    testimony.append([list(map(int, input().split())) for _ in range(A)]) +ans = 0 +for bit in itertools.product([0, 1], repeat=N): +    for n in range(N): +        if bit[n]: +            for t in testimony[n]: +                if bit[t[0] - 1] != t[1]: -                #                 print("continue") -            #             print("break") -        #         print("new_ans") -        ans = max(ans, honest_cnt) +        ans = max(ans, sum(bit))