import sys

input = sys.stdin.readline

import numpy as np

N = int(eval(input()))

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

for i in range(N):

    A = int(eval(input()))

    temp = []

    for _ in range(A):

        temp.append([str(x) for x in input().split()])

        S[i] = temp

ans = 0

for i in range(2 ** N - 1, -1,-1):

    biti = list(bin(i)[2:].zfill(N))

    flag = 0

    for j in range(N):

        if biti[j] == "1":

            for k in S[j]:

                if biti[int(k[0])-1] != k[1]:

                    flag = 1

                    break

        if flag:

            break

    if not flag:    

        biti = np.array(biti)

        ans = max(ans, np.count_nonzero(biti == "1"))

print(ans)
import sys

input = sys.stdin.readline



n = int(eval(input()))



from collections import defaultdict

d = defaultdict(list)



for i in range(n):

    a = int(eval(input()))

    for _ in range(a):

        x, y = [int(x) for x in input().split()]

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

ans = 0

for k in range(2**n):

    res = 0

    j = bin(k)[2:].zfill(n)

    flag = 1

    for i in range(n):

        if j[i] == "0":

            continue

        for x, y in d[i]:

            if int(j[x]) != int(y):

                flag = 0

                break

        res += 1

    if flag:

        ans = max(ans, res)

print(ans)
import sys

input = sys.stdin.readline
import numpy as np

N = int(eval(input()))
S = [[] for _ in range(N)]
for i in range(N):
    A = int(eval(input()))
    temp = []
    for _ in range(A):
        temp.append([str(x) for x in input().split()])
        S[i] = temp
ans = 0
for i in range(2**N - 1, -1, -1):
    biti = list(bin(i)[2:].zfill(N))
    flag = 0
    for j in range(N):
        if biti[j] == "1":
            for k in S[j]:
                if biti[int(k[0]) - 1] != k[1]:
                    flag = 1
                    break
        if flag:
            break
    if not flag:
        biti = np.array(biti)
        ans = max(ans, np.count_nonzero(biti == "1"))
print(ans)

import sys

input = sys.stdin.readline
n = int(eval(input()))
from collections import defaultdict

d = defaultdict(list)
for i in range(n):
    a = int(eval(input()))
    for _ in range(a):
        x, y = [int(x) for x in input().split()]
        d[i].append((x - 1, y))
ans = 0
for k in range(2**n):
    res = 0
    j = bin(k)[2:].zfill(n)
    flag = 1
    for i in range(n):
        if j[i] == "0":
            continue
        for x, y in d[i]:
            if int(j[x]) != int(y):
                flag = 0
                break
        res += 1
    if flag:
        ans = max(ans, res)
print(ans)

-import numpy as np +n = int(eval(input())) +from collections import defaultdict -N = int(eval(input())) -S = [[] for _ in range(N)] -for i in range(N): -    A = int(eval(input())) -    temp = [] -    for _ in range(A): -        temp.append([str(x) for x in input().split()]) -        S[i] = temp +d = defaultdict(list) +for i in range(n): +    a = int(eval(input())) +    for _ in range(a): +        x, y = [int(x) for x in input().split()] +        d[i].append((x - 1, y)) -for i in range(2**N - 1, -1, -1): -    biti = list(bin(i)[2:].zfill(N)) -    flag = 0 -    for j in range(N): -        if biti[j] == "1": -            for k in S[j]: -                if biti[int(k[0]) - 1] != k[1]: -                    flag = 1 -                    break -        if flag: -            break -    if not flag: -        biti = np.array(biti) -        ans = max(ans, np.count_nonzero(biti == "1")) +for k in range(2**n): +    res = 0 +    j = bin(k)[2:].zfill(n) +    flag = 1 +    for i in range(n): +        if j[i] == "0": +            continue +        for x, y in d[i]: +            if int(j[x]) != int(y): +                flag = 0 +                break +        res += 1 +    if flag: +        ans = max(ans, res)