N=int(eval(input()))

A=[]

X=list()

for i in range(N):

   X.append([])



Y=list()

for i in range(N):

   Y.append([])



for i in range(N):

   A_i=int(eval(input()))

   A.append(A_i)



   for j in range(A_i):

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

      X[i].append(x)

      Y[i].append(y)



max_nin=0

#bit全探索

for i in range(1<<N):

   honest_kamo=[]

   for j in range(N):

      if(i>>j)&1:

         honest_kamo.append(j)



   liar_kamo=[c for c in range(N)]

   liar_kamo=list(set(liar_kamo)-set(honest_kamo))

   #print("honest_kamo:",honest_kamo)

   #print("liar_kamo:",liar_kamo)



   flag=True

   for i in honest_kamo:

      for j in range(A[i]):

         if Y[i][j]==1:

            if X[i][j]-1 in liar_kamo:

               flag=False

         elif Y[i][j]==0:

            if X[i][j]-1 in honest_kamo:

               flag=False

   

   #print(flag)

   if flag:

      max_nin=max(max_nin,len(honest_kamo))



print(max_nin)
from sys import stdin

def main():

    #入力

    readline=stdin.readline

    n=int(readline())

    shogen=[]

    nums=[]

    for i in range(n):

        a=int(readline())

        nums.append(a)

        xy=[0]*a

        for j in range(a):

            xy[j]=list(map(int,readline().split()))

        shogen.append(xy)

    

    res=0

    for i in range(1<<n):

        output=[]

        for j in range(n):

            if(i>>j)&1:

                output.append(j)

        

        flag=True

        for p in output:

            num_p=nums[p]

            shogen_p=shogen[p]

            for j in range(num_p):

                if shogen_p[j][1]==1:

                    if shogen_p[j][0]-1 in output:

                        pass

                    else:

                        flag=False

                        break

                else:

                    if shogen_p[j][0]-1 in output:

                        flag=False

                        break

                    else:

                        pass

            if flag==False:

                break

        else:

            res=max(res,len(output))



    print(res)



if __name__=="__main__":

    main()
N = int(eval(input()))
A = []
X = list()
for i in range(N):
    X.append([])
Y = list()
for i in range(N):
    Y.append([])
for i in range(N):
    A_i = int(eval(input()))
    A.append(A_i)
    for j in range(A_i):
        x, y = list(map(int, input().split()))
        X[i].append(x)
        Y[i].append(y)
max_nin = 0
# bit全探索
for i in range(1 << N):
    honest_kamo = []
    for j in range(N):
        if (i >> j) & 1:
            honest_kamo.append(j)
    liar_kamo = [c for c in range(N)]
    liar_kamo = list(set(liar_kamo) - set(honest_kamo))
    # print("honest_kamo:",honest_kamo)
    # print("liar_kamo:",liar_kamo)
    flag = True
    for i in honest_kamo:
        for j in range(A[i]):
            if Y[i][j] == 1:
                if X[i][j] - 1 in liar_kamo:
                    flag = False
            elif Y[i][j] == 0:
                if X[i][j] - 1 in honest_kamo:
                    flag = False
    # print(flag)
    if flag:
        max_nin = max(max_nin, len(honest_kamo))
print(max_nin)

from sys import stdin


def main():
    # 入力
    readline = stdin.readline
    n = int(readline())
    shogen = []
    nums = []
    for i in range(n):
        a = int(readline())
        nums.append(a)
        xy = [0] * a
        for j in range(a):
            xy[j] = list(map(int, readline().split()))
        shogen.append(xy)
    res = 0
    for i in range(1 << n):
        output = []
        for j in range(n):
            if (i >> j) & 1:
                output.append(j)
        flag = True
        for p in output:
            num_p = nums[p]
            shogen_p = shogen[p]
            for j in range(num_p):
                if shogen_p[j][1] == 1:
                    if shogen_p[j][0] - 1 in output:
                        pass
                    else:
                        flag = False
                        break
                else:
                    if shogen_p[j][0] - 1 in output:
                        flag = False
                        break
                    else:
                        pass
            if flag == False:
                break
        else:
            res = max(res, len(output))
    print(res)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -A = [] -X = list() -for i in range(N): -    X.append([]) -Y = list() -for i in range(N): -    Y.append([]) -for i in range(N): -    A_i = int(eval(input())) -    A.append(A_i) -    for j in range(A_i): -        x, y = list(map(int, input().split())) -        X[i].append(x) -        Y[i].append(y) -max_nin = 0 -# bit全探索 -for i in range(1 << N): -    honest_kamo = [] -    for j in range(N): -        if (i >> j) & 1: -            honest_kamo.append(j) -    liar_kamo = [c for c in range(N)] -    liar_kamo = list(set(liar_kamo) - set(honest_kamo)) -    # print("honest_kamo:",honest_kamo) -    # print("liar_kamo:",liar_kamo) -    flag = True -    for i in honest_kamo: -        for j in range(A[i]): -            if Y[i][j] == 1: -                if X[i][j] - 1 in liar_kamo: -                    flag = False -            elif Y[i][j] == 0: -                if X[i][j] - 1 in honest_kamo: -                    flag = False -    # print(flag) -    if flag: -        max_nin = max(max_nin, len(honest_kamo)) -print(max_nin) +from sys import stdin + + +def main(): +    # 入力 +    readline = stdin.readline +    n = int(readline()) +    shogen = [] +    nums = [] +    for i in range(n): +        a = int(readline()) +        nums.append(a) +        xy = [0] * a +        for j in range(a): +            xy[j] = list(map(int, readline().split())) +        shogen.append(xy) +    res = 0 +    for i in range(1 << n): +        output = [] +        for j in range(n): +            if (i >> j) & 1: +                output.append(j) +        flag = True +        for p in output: +            num_p = nums[p] +            shogen_p = shogen[p] +            for j in range(num_p): +                if shogen_p[j][1] == 1: +                    if shogen_p[j][0] - 1 in output: +                        pass +                    else: +                        flag = False +                        break +                else: +                    if shogen_p[j][0] - 1 in output: +                        flag = False +                        break +                    else: +                        pass +            if flag == False: +                break +        else: +            res = max(res, len(output)) +    print(res) + + +if __name__ == "__main__": +    main()