#!/usr/bin/env python3

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 7)



N = int(readline())

tes = [[-1]*N for i in range(N)]

for i in range(N):

    A = int(readline())

    for j in range(A):

        x,y = list(map(int,readline().rstrip().split()))

        tes[i][x-1] = y #ここまでが入力



cnt = 0

for i in range(2**N):

    hon = [0]*N

    for j in range(N):

        if (i>>j)&1:

            hon[j] = 1 #全状態2**N通りを作っておく

    flag = True

    for j in range(N):

        if hon[j]:      #hon=1ならtesとの整合性を比較

            for k in range(N):

                if tes[j][k] == -1:

                    continue    #証言されていない部分は飛ばす

                if tes[j][k] != hon[k]:

                    flag = False

    if flag:

        cnt = max(cnt,hon.count(1))

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

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 7)



N = int(readline())

tes = [[-1]*N for i in range(N)]

for i in range(N):

    A = int(readline())

    for j in range(A):

        x,y = list(map(int,readline().rstrip().split()))

        tes[i][x-1] = y



cnt = 0

for i in range(2**N):

    hon = [0]*N

    for j in range(N):

        if (i>>j)&1:

            hon[j] = 1

    flag = True

    for j in range(N):

        if hon[j]:

            for k in range(N):

                if tes[j][k] == -1:

                    continue

                if tes[j][k] != hon[k]:

                    flag = False

                    break

        if not flag:

            break

    if flag:

        cnt = max(cnt,hon.count(1))

print(cnt)
#!/usr/bin/env python3
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**7)
N = int(readline())
tes = [[-1] * N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x, y = list(map(int, readline().rstrip().split()))
        tes[i][x - 1] = y  # ここまでが入力
cnt = 0
for i in range(2**N):
    hon = [0] * N
    for j in range(N):
        if (i >> j) & 1:
            hon[j] = 1  # 全状態2**N通りを作っておく
    flag = True
    for j in range(N):
        if hon[j]:  # hon=1ならtesとの整合性を比較
            for k in range(N):
                if tes[j][k] == -1:
                    continue  # 証言されていない部分は飛ばす
                if tes[j][k] != hon[k]:
                    flag = False
    if flag:
        cnt = max(cnt, hon.count(1))
print(cnt)

#!/usr/bin/env python3
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**7)
N = int(readline())
tes = [[-1] * N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x, y = list(map(int, readline().rstrip().split()))
        tes[i][x - 1] = y
cnt = 0
for i in range(2**N):
    hon = [0] * N
    for j in range(N):
        if (i >> j) & 1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if hon[j]:
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
        if not flag:
            break
    if flag:
        cnt = max(cnt, hon.count(1))
print(cnt)

-        tes[i][x - 1] = y  # ここまでが入力 +        tes[i][x - 1] = y -            hon[j] = 1  # 全状態2**N通りを作っておく +            hon[j] = 1 -        if hon[j]:  # hon=1ならtesとの整合性を比較 +        if hon[j]: -                    continue  # 証言されていない部分は飛ばす +                    continue +                    break +        if not flag: +            break