def solve():

    n=int(eval(input()))

    ev=[[] for _ in range(n)]

    for i in range(n):

        a=int(eval(input()))

        l=[]

        for j in range(a):#証言

        

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

            l.append([x-1,y])

        ev[i]=l

    

    ans=0

    

    for i in range(2**n):

        result=0

        honest=[]

        for j in range(n):

            

            if ((i>>j)&1): #jは正直者

                honest+=ev[j]

                #正直者と仮定した人の証言を集める    

                

        for j in range(n):

            

            if ((i>>j)&1): #jは正直者

                result+=1

                if [j,0] in honest:

                    result=0

                    break

            else:

                if [j,1] in honest:

                    result=0

                    break

                    

        ans=max(ans,result)

        

    print(ans)

    

solve()
n=int(eval(input()))

evi=[]

for i in range(n):

    a=int(eval(input()))

    l=[list(map(int,input().split())) for i in range(a)]

    evi+=[l]#証言をすべて集める

ans=0

for i in range(2**n):

    mujyun=[]

    h_list=[]

    count=0

    for j in range(n):

        if ((i>>j)&1):#各桁が１かどうか

            count+=1

            mujyun+=[[j+1,0]]#仮定が間違っているとする    

            h_list+=evi[j]#正直者の発言

        else:

            mujyun+=[[j+1,1]]

        

    for k in mujyun:

        if k in h_list:#矛盾が生じる

            count=0

            break

        

    ans=max(ans,count)

print(ans)
def solve():
    n = int(eval(input()))
    ev = [[] for _ in range(n)]
    for i in range(n):
        a = int(eval(input()))
        l = []
        for j in range(a):  # 証言
            x, y = list(map(int, input().split()))
            l.append([x - 1, y])
        ev[i] = l
    ans = 0
    for i in range(2**n):
        result = 0
        honest = []
        for j in range(n):
            if (i >> j) & 1:  # jは正直者
                honest += ev[j]
                # 正直者と仮定した人の証言を集める
        for j in range(n):
            if (i >> j) & 1:  # jは正直者
                result += 1
                if [j, 0] in honest:
                    result = 0
                    break
            else:
                if [j, 1] in honest:
                    result = 0
                    break
        ans = max(ans, result)
    print(ans)


solve()

n = int(eval(input()))
evi = []
for i in range(n):
    a = int(eval(input()))
    l = [list(map(int, input().split())) for i in range(a)]
    evi += [l]  # 証言をすべて集める
ans = 0
for i in range(2**n):
    mujyun = []
    h_list = []
    count = 0
    for j in range(n):
        if (i >> j) & 1:  # 各桁が１かどうか
            count += 1
            mujyun += [[j + 1, 0]]  # 仮定が間違っているとする
            h_list += evi[j]  # 正直者の発言
        else:
            mujyun += [[j + 1, 1]]
    for k in mujyun:
        if k in h_list:  # 矛盾が生じる
            count = 0
            break
    ans = max(ans, count)
print(ans)

-def solve(): -    n = int(eval(input())) -    ev = [[] for _ in range(n)] -    for i in range(n): -        a = int(eval(input())) -        l = [] -        for j in range(a):  # 証言 -            x, y = list(map(int, input().split())) -            l.append([x - 1, y]) -        ev[i] = l -    ans = 0 -    for i in range(2**n): -        result = 0 -        honest = [] -        for j in range(n): -            if (i >> j) & 1:  # jは正直者 -                honest += ev[j] -                # 正直者と仮定した人の証言を集める -        for j in range(n): -            if (i >> j) & 1:  # jは正直者 -                result += 1 -                if [j, 0] in honest: -                    result = 0 -                    break -            else: -                if [j, 1] in honest: -                    result = 0 -                    break -        ans = max(ans, result) -    print(ans) - - -solve() +n = int(eval(input())) +evi = [] +for i in range(n): +    a = int(eval(input())) +    l = [list(map(int, input().split())) for i in range(a)] +    evi += [l]  # 証言をすべて集める +ans = 0 +for i in range(2**n): +    mujyun = [] +    h_list = [] +    count = 0 +    for j in range(n): +        if (i >> j) & 1:  # 各桁が１かどうか +            count += 1 +            mujyun += [[j + 1, 0]]  # 仮定が間違っているとする +            h_list += evi[j]  # 正直者の発言 +        else: +            mujyun += [[j + 1, 1]] +    for k in mujyun: +        if k in h_list:  # 矛盾が生じる +            count = 0 +            break +    ans = max(ans, count) +print(ans)