def check(x, y):

    for a, b in zip(x, y):

        if a != b and b != -1:

            return False

    else:

        return True





n = int(eval(input()))

remarks = []

cnt_max = 0

for _ in range(n):

    a = int(eval(input()))

    x = [tuple(map(int, input().split())) for i in range(a)]

    r = [-1] * n

    for i, j in x:

        r[i - 1] = j

    remarks.append(r)

for r in range(2 ** n):

    r = list(bin(r)[2:].zfill(n))

    r = [int(i) for i in r[:]]

    cnt = 0

    for i in range(n):

        if r[i] == 1:

            flag = check(r, remarks[i])

            cnt += 1

            if not flag:

                cnt = 0

                break

    cnt_max = max(cnt, cnt_max)

print(cnt_max)
import numpy as np

import itertools



n = int(eval(input()))

info = []

for i in range(n):

    a = int(eval(input()))

    for _ in range(a):

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

        info.append((i, x - 1, y))



a = np.array(list(itertools.product([0, 1], repeat=n)), dtype=np.bool)

for i, x, y in info:

    bl = (~a[:, i]) | (a[:, x] == bool(y))

    a = a[bl]



ans = a.sum(axis=1).max()

print(ans)
def check(x, y):
    for a, b in zip(x, y):
        if a != b and b != -1:
            return False
    else:
        return True


n = int(eval(input()))
remarks = []
cnt_max = 0
for _ in range(n):
    a = int(eval(input()))
    x = [tuple(map(int, input().split())) for i in range(a)]
    r = [-1] * n
    for i, j in x:
        r[i - 1] = j
    remarks.append(r)
for r in range(2**n):
    r = list(bin(r)[2:].zfill(n))
    r = [int(i) for i in r[:]]
    cnt = 0
    for i in range(n):
        if r[i] == 1:
            flag = check(r, remarks[i])
            cnt += 1
            if not flag:
                cnt = 0
                break
    cnt_max = max(cnt, cnt_max)
print(cnt_max)

import numpy as np
import itertools

n = int(eval(input()))
info = []
for i in range(n):
    a = int(eval(input()))
    for _ in range(a):
        x, y = list(map(int, input().split()))
        info.append((i, x - 1, y))
a = np.array(list(itertools.product([0, 1], repeat=n)), dtype=np.bool)
for i, x, y in info:
    bl = (~a[:, i]) | (a[:, x] == bool(y))
    a = a[bl]
ans = a.sum(axis=1).max()
print(ans)

-def check(x, y): -    for a, b in zip(x, y): -        if a != b and b != -1: -            return False -    else: -        return True - +import numpy as np +import itertools -remarks = [] -cnt_max = 0 -for _ in range(n): +info = [] +for i in range(n): -    x = [tuple(map(int, input().split())) for i in range(a)] -    r = [-1] * n -    for i, j in x: -        r[i - 1] = j -    remarks.append(r) -for r in range(2**n): -    r = list(bin(r)[2:].zfill(n)) -    r = [int(i) for i in r[:]] -    cnt = 0 -    for i in range(n): -        if r[i] == 1: -            flag = check(r, remarks[i]) -            cnt += 1 -            if not flag: -                cnt = 0 -                break -    cnt_max = max(cnt, cnt_max) -print(cnt_max) +    for _ in range(a): +        x, y = list(map(int, input().split())) +        info.append((i, x - 1, y)) +a = np.array(list(itertools.product([0, 1], repeat=n)), dtype=np.bool) +for i, x, y in info: +    bl = (~a[:, i]) | (a[:, x] == bool(y)) +    a = a[bl] +ans = a.sum(axis=1).max() +print(ans)