def main():

    N = int(eval(input()))

     

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

     

    for i in range(N):

        num = int(eval(input()))

        for j in range(num):

            person, state = list(map(int, input().split()))

            testimony[i].append([person-1, state])

            

    honest = 0

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

        flag = 0

        for j in range(N):

            if (i>>j)&1 == 1: # j番目は正直と仮定

                for x,y in testimony[j]:

                    if (i>>x)&1 != y: # j番目は正直だが矛盾を発見

                        flag = 1

                        break

        if flag == 0:  # 矛盾がある場合はflag == 1になる

            honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択

    print(honest)

if __name__=="__main__":

    main()
from itertools import product

N=int(eval(input()))

data=[]

for i in range(N):

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

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

        data.append((i,x-1,y))

#print(data)



ans=0

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

    #print(i)

    s=True

    for k in data:

        if i[k[0]]==1 and i[k[1]]!=k[2]:

            s=False

            break

    if s:

        ans=max(ans,sum(i))

print(ans)

def main():
    N = int(eval(input()))
    testimony = [[] for _ in range(N)]
    for i in range(N):
        num = int(eval(input()))
        for j in range(num):
            person, state = list(map(int, input().split()))
            testimony[i].append([person - 1, state])
    honest = 0
    for i in range(1, 2**N):
        flag = 0
        for j in range(N):
            if (i >> j) & 1 == 1:  # j番目は正直と仮定
                for x, y in testimony[j]:
                    if (i >> x) & 1 != y:  # j番目は正直だが矛盾を発見
                        flag = 1
                        break
        if flag == 0:  # 矛盾がある場合はflag == 1になる
            honest = max(honest, bin(i)[2:].count("1"))  # 1の数をカウントし最大となるものを選択
    print(honest)


if __name__ == "__main__":
    main()

from itertools import product

N = int(eval(input()))
data = []
for i in range(N):
    for j in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        data.append((i, x - 1, y))
# print(data)
ans = 0
for i in product([1, 0], repeat=N):
    # print(i)
    s = True
    for k in data:
        if i[k[0]] == 1 and i[k[1]] != k[2]:
            s = False
            break
    if s:
        ans = max(ans, sum(i))
print(ans)

-def main(): -    N = int(eval(input())) -    testimony = [[] for _ in range(N)] -    for i in range(N): -        num = int(eval(input())) -        for j in range(num): -            person, state = list(map(int, input().split())) -            testimony[i].append([person - 1, state]) -    honest = 0 -    for i in range(1, 2**N): -        flag = 0 -        for j in range(N): -            if (i >> j) & 1 == 1:  # j番目は正直と仮定 -                for x, y in testimony[j]: -                    if (i >> x) & 1 != y:  # j番目は正直だが矛盾を発見 -                        flag = 1 -                        break -        if flag == 0:  # 矛盾がある場合はflag == 1になる -            honest = max(honest, bin(i)[2:].count("1"))  # 1の数をカウントし最大となるものを選択 -    print(honest) +from itertools import product - -if __name__ == "__main__": -    main() +N = int(eval(input())) +data = [] +for i in range(N): +    for j in range(int(eval(input()))): +        x, y = list(map(int, input().split())) +        data.append((i, x - 1, y)) +# print(data) +ans = 0 +for i in product([1, 0], repeat=N): +    # print(i) +    s = True +    for k in data: +        if i[k[0]] == 1 and i[k[1]] != k[2]: +            s = False +            break +    if s: +        ans = max(ans, sum(i)) +print(ans)