n,ans=int(eval(input())),0

xy=[[list(map(int,input().split())) for _ in range(int(eval(input())))] for _ in range(n)]

for i in range(2**n):

  f=True         

  for j in range(n):

    if (i>>j)&1:    

      for x,y in xy[j]:

        if (i>>(x-1))&1!=y:

          f=False

          break

  if f: 

    ans=max(ans,bin(i)[2:].count('1'))     

print(ans)
from itertools import *

N = int(eval(input()))

H = []

A = []



for i in range(N):

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

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

    H+=[[i,x-1,y]]



for P in product([0,1],repeat=N):

  for h in H:

    if P[h[0]]==1 and P[h[1]]!=h[2]:

      break

  else:

    A+=[sum(P)]



print((max(A)))
n, ans = int(eval(input())), 0
xy = [
    [list(map(int, input().split())) for _ in range(int(eval(input())))]
    for _ in range(n)
]
for i in range(2**n):
    f = True
    for j in range(n):
        if (i >> j) & 1:
            for x, y in xy[j]:
                if (i >> (x - 1)) & 1 != y:
                    f = False
                    break
    if f:
        ans = max(ans, bin(i)[2:].count("1"))
print(ans)

from itertools import *

N = int(eval(input()))
H = []
A = []
for i in range(N):
    for j in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        H += [[i, x - 1, y]]
for P in product([0, 1], repeat=N):
    for h in H:
        if P[h[0]] == 1 and P[h[1]] != h[2]:
            break
    else:
        A += [sum(P)]
print((max(A)))

-n, ans = int(eval(input())), 0 -xy = [ -    [list(map(int, input().split())) for _ in range(int(eval(input())))] -    for _ in range(n) -] -for i in range(2**n): -    f = True -    for j in range(n): -        if (i >> j) & 1: -            for x, y in xy[j]: -                if (i >> (x - 1)) & 1 != y: -                    f = False -                    break -    if f: -        ans = max(ans, bin(i)[2:].count("1")) -print(ans) +from itertools import * + +N = int(eval(input())) +H = [] +A = [] +for i in range(N): +    for j in range(int(eval(input()))): +        x, y = list(map(int, input().split())) +        H += [[i, x - 1, y]] +for P in product([0, 1], repeat=N): +    for h in H: +        if P[h[0]] == 1 and P[h[1]] != h[2]: +            break +    else: +        A += [sum(P)] +print((max(A)))