n=int(eval(input()))

xy=[]

for i in range(n):

  a=int(eval(input()))

  xy.append([list(map(int,input().split())) for j in range(a)])



ans=[]

for i in range(2**n):

  honest=[]

  for j in range(n):

    if (i>>j)&1:

      honest.append(1)

    else:

      honest.append(0)

  p=0

  q=0

  for j,k in enumerate(honest):

    if k==1:

      q=q+1

      r=0

      for l in xy[j]:

        if honest[l[0]-1]==l[1]:

          r=r+1

      if r==len(xy[j]):

        p=p+1

  if p==q:

    ans.append(p)

print((max(ans)))
n=int(eval(input()))

xy=[]

for i in range(n):

  a=int(eval(input()))

  xy.append([list(map(int,input().split())) for j in range(a)])

 

ans=0

for i in range(2**n):

  honest=[]

  for j in range(n):

    if (i>>j)&1:

      honest.append(1)

    else:

      honest.append(0)

  p=0

  for j,k in enumerate(honest):

    if k==1:

      r=0

      for l in xy[j]:

        if honest[l[0]-1]!=l[1]:

          r=1

          break    

      if r==0:

        p=p+1

  if p==sum(honest) and p>ans:

    ans=p

print(ans)
n = int(eval(input()))
xy = []
for i in range(n):
    a = int(eval(input()))
    xy.append([list(map(int, input().split())) for j in range(a)])
ans = []
for i in range(2**n):
    honest = []
    for j in range(n):
        if (i >> j) & 1:
            honest.append(1)
        else:
            honest.append(0)
    p = 0
    q = 0
    for j, k in enumerate(honest):
        if k == 1:
            q = q + 1
            r = 0
            for l in xy[j]:
                if honest[l[0] - 1] == l[1]:
                    r = r + 1
            if r == len(xy[j]):
                p = p + 1
    if p == q:
        ans.append(p)
print((max(ans)))

n = int(eval(input()))
xy = []
for i in range(n):
    a = int(eval(input()))
    xy.append([list(map(int, input().split())) for j in range(a)])
ans = 0
for i in range(2**n):
    honest = []
    for j in range(n):
        if (i >> j) & 1:
            honest.append(1)
        else:
            honest.append(0)
    p = 0
    for j, k in enumerate(honest):
        if k == 1:
            r = 0
            for l in xy[j]:
                if honest[l[0] - 1] != l[1]:
                    r = 1
                    break
            if r == 0:
                p = p + 1
    if p == sum(honest) and p > ans:
        ans = p
print(ans)

-ans = [] +ans = 0 -    q = 0 -            q = q + 1 -                if honest[l[0] - 1] == l[1]: -                    r = r + 1 -            if r == len(xy[j]): +                if honest[l[0] - 1] != l[1]: +                    r = 1 +                    break +            if r == 0: -    if p == q: -        ans.append(p) -print((max(ans))) +    if p == sum(honest) and p > ans: +        ans = p +print(ans)