N = int(eval(input()))

A = []

XY = []

honest_count = []



for i in range (N):

    a = int(eval(input()))

    A.append(a)

    inter = []

    for x in range(a):

        xy = list(map(int, input().split()))

        inter.append(xy)

    XY.append(inter)



for i in range(2 ** N):

    pt = [0] * N

    ck = 1

    for j in range(N):

        if (i >> j) & 1:

            pt[N - j - 1] = 1



    for k in range(N): # k人目が正直者の場合チェック

        if pt[k] == 1:

            for l in range(A[k]):

                if XY[k][l][1] != pt[XY[k][l][0] - 1]:

                    ck = 0

    if ck == 1:

        honest_count.append(sum(pt))





print((max(honest_count)))
import itertools

n = int(eval(input()))

l = []

for i in range(n):

    d = int(eval(input()))

    for dd in range(d):

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

        l.append([i, x-1, y])



ans = 0

for p in itertools.product([0, 1], repeat=n):

    for ll in l:

        if p[ll[0]] == 1 and p[ll[1]] != ll[2]:

            break

    else:

        ans = max(ans, sum(p))

print(ans)
N = int(eval(input()))
A = []
XY = []
honest_count = []
for i in range(N):
    a = int(eval(input()))
    A.append(a)
    inter = []
    for x in range(a):
        xy = list(map(int, input().split()))
        inter.append(xy)
    XY.append(inter)
for i in range(2**N):
    pt = [0] * N
    ck = 1
    for j in range(N):
        if (i >> j) & 1:
            pt[N - j - 1] = 1
    for k in range(N):  # k人目が正直者の場合チェック
        if pt[k] == 1:
            for l in range(A[k]):
                if XY[k][l][1] != pt[XY[k][l][0] - 1]:
                    ck = 0
    if ck == 1:
        honest_count.append(sum(pt))
print((max(honest_count)))

import itertools

n = int(eval(input()))
l = []
for i in range(n):
    d = int(eval(input()))
    for dd in range(d):
        x, y = list(map(int, input().split()))
        l.append([i, x - 1, y])
ans = 0
for p in itertools.product([0, 1], repeat=n):
    for ll in l:
        if p[ll[0]] == 1 and p[ll[1]] != ll[2]:
            break
    else:
        ans = max(ans, sum(p))
print(ans)

-N = int(eval(input())) -A = [] -XY = [] -honest_count = [] -for i in range(N): -    a = int(eval(input())) -    A.append(a) -    inter = [] -    for x in range(a): -        xy = list(map(int, input().split())) -        inter.append(xy) -    XY.append(inter) -for i in range(2**N): -    pt = [0] * N -    ck = 1 -    for j in range(N): -        if (i >> j) & 1: -            pt[N - j - 1] = 1 -    for k in range(N):  # k人目が正直者の場合チェック -        if pt[k] == 1: -            for l in range(A[k]): -                if XY[k][l][1] != pt[XY[k][l][0] - 1]: -                    ck = 0 -    if ck == 1: -        honest_count.append(sum(pt)) -print((max(honest_count))) +import itertools + +n = int(eval(input())) +l = [] +for i in range(n): +    d = int(eval(input())) +    for dd in range(d): +        x, y = list(map(int, input().split())) +        l.append([i, x - 1, y]) +ans = 0 +for p in itertools.product([0, 1], repeat=n): +    for ll in l: +        if p[ll[0]] == 1 and p[ll[1]] != ll[2]: +            break +    else: +        ans = max(ans, sum(p)) +print(ans)