n=int(eval(input()))

w=[[] for i in range(n)]

for i in range(n):

    a=int(eval(input()))

    for j in range(a):

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

        w[i].append((x,y))

ans=0

for i in range(1<<n):

    x="0"*15+bin(i)[2:]

    z=[int(i) for i in x[-n:]]

    f=1

    for p,q in enumerate(w):

        if z[p]==1:

            for r in q:

                if (z[r[0]-1]!=r[1]):

                    f=0

    if f:

        ans=max(ans,z.count(1))

print(ans)
#!/usr/bin/env python3

# -*- coding: UTF-8 -*-



n=int(eval(input()))

w=[]

ans=chk=0

for i in range(n):

    a=int(eval(input()))

    t=[]

    for j in range(a):

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

        t.append((x,y))

    w.append(t)

for i in range(1,2**n):

    l=[0]*n

    for j in range(n):

        if i&1: l[j]=1

        i=i>>1

    chk=1

    for j in range(n):

        if l[j]:

            for k in w[j]:

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

                    chk=0

                    break

    if chk: ans=max(ans,sum(l))

print(ans)

n = int(eval(input()))
w = [[] for i in range(n)]
for i in range(n):
    a = int(eval(input()))
    for j in range(a):
        x, y = list(map(int, input().split()))
        w[i].append((x, y))
ans = 0
for i in range(1 << n):
    x = "0" * 15 + bin(i)[2:]
    z = [int(i) for i in x[-n:]]
    f = 1
    for p, q in enumerate(w):
        if z[p] == 1:
            for r in q:
                if z[r[0] - 1] != r[1]:
                    f = 0
    if f:
        ans = max(ans, z.count(1))
print(ans)

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
n = int(eval(input()))
w = []
ans = chk = 0
for i in range(n):
    a = int(eval(input()))
    t = []
    for j in range(a):
        x, y = list(map(int, input().split()))
        t.append((x, y))
    w.append(t)
for i in range(1, 2**n):
    l = [0] * n
    for j in range(n):
        if i & 1:
            l[j] = 1
        i = i >> 1
    chk = 1
    for j in range(n):
        if l[j]:
            for k in w[j]:
                if l[k[0] - 1] != k[1]:
                    chk = 0
                    break
    if chk:
        ans = max(ans, sum(l))
print(ans)

+#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- -w = [[] for i in range(n)] +w = [] +ans = chk = 0 +    t = [] -        w[i].append((x, y)) -ans = 0 -for i in range(1 << n): -    x = "0" * 15 + bin(i)[2:] -    z = [int(i) for i in x[-n:]] -    f = 1 -    for p, q in enumerate(w): -        if z[p] == 1: -            for r in q: -                if z[r[0] - 1] != r[1]: -                    f = 0 -    if f: -        ans = max(ans, z.count(1)) +        t.append((x, y)) +    w.append(t) +for i in range(1, 2**n): +    l = [0] * n +    for j in range(n): +        if i & 1: +            l[j] = 1 +        i = i >> 1 +    chk = 1 +    for j in range(n): +        if l[j]: +            for k in w[j]: +                if l[k[0] - 1] != k[1]: +                    chk = 0 +                    break +    if chk: +        ans = max(ans, sum(l))