n=int(eval(input()))

al=[]

l=[]

for i in range(n):

  a=int(eval(input()))

  al.append(a)

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

  l.append(templ)

ans=0

for i in range(2**n):

  b=bin(i)

  chkdic={}

  n_honest=0#正直者の人数をカウント

  flag=False#矛盾が生じるかどうか

  for j in range(n):

    if ((i >> j) & 1):#もし正直者なら

      n_honest+=1

      #saying_l=l[j]

      #a=al[j]

      chkdic[j+1]=1

    else:

      chkdic[j+1]=0

  #chkdicをもとに判定

  for j in range(n):

    if ((i >> j) & 1):

      saying_l=l[j]

      a=al[j]

      for k in range(a):

        saying=saying_l[k]

        if chkdic[saying[0]]!=saying[1]:

          flag=True

          break

    if flag:

      break  

  if not flag:

    ans=max(ans,n_honest)

print(ans)

      



n=int(eval(input()))

al=[]

info=[]

for i in range(n):

    a=int(eval(input()))

    al.append(a)

    temp=[]

    for j in range(a):

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

        temp.append([x,y])

    info.append(temp)



ans=0



for i in range(2**n):

    n_honest=0

    dic={}

    flag=True

    for j in range(n):

        if ((i >> j) & 1):

            n_honest+=1

            dic[j]=1

        else:

            dic[j]=0

    for j in range(n):

        if ((i >> j) & 1):

            temp=info[j]

            a=al[j]

            for k in range(a):

                l=temp[k]

                x=l[0]

                y=l[1]

                if dic[x-1]!=y:

                    flag=False

                    break

        if not flag:

            break

    if flag:

        ans=max(n_honest,ans)

print(ans)



n = int(eval(input()))
al = []
l = []
for i in range(n):
    a = int(eval(input()))
    al.append(a)
    templ = [list(map(int, input().split())) for i in range(a)]
    l.append(templ)
ans = 0
for i in range(2**n):
    b = bin(i)
    chkdic = {}
    n_honest = 0  # 正直者の人数をカウント
    flag = False  # 矛盾が生じるかどうか
    for j in range(n):
        if (i >> j) & 1:  # もし正直者なら
            n_honest += 1
            # saying_l=l[j]
            # a=al[j]
            chkdic[j + 1] = 1
        else:
            chkdic[j + 1] = 0
    # chkdicをもとに判定
    for j in range(n):
        if (i >> j) & 1:
            saying_l = l[j]
            a = al[j]
            for k in range(a):
                saying = saying_l[k]
                if chkdic[saying[0]] != saying[1]:
                    flag = True
                    break
        if flag:
            break
    if not flag:
        ans = max(ans, n_honest)
print(ans)

n = int(eval(input()))
al = []
info = []
for i in range(n):
    a = int(eval(input()))
    al.append(a)
    temp = []
    for j in range(a):
        x, y = list(map(int, input().split()))
        temp.append([x, y])
    info.append(temp)
ans = 0
for i in range(2**n):
    n_honest = 0
    dic = {}
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            n_honest += 1
            dic[j] = 1
        else:
            dic[j] = 0
    for j in range(n):
        if (i >> j) & 1:
            temp = info[j]
            a = al[j]
            for k in range(a):
                l = temp[k]
                x = l[0]
                y = l[1]
                if dic[x - 1] != y:
                    flag = False
                    break
        if not flag:
            break
    if flag:
        ans = max(n_honest, ans)
print(ans)

-l = [] +info = [] -    templ = [list(map(int, input().split())) for i in range(a)] -    l.append(templ) +    temp = [] +    for j in range(a): +        x, y = list(map(int, input().split())) +        temp.append([x, y]) +    info.append(temp) -    b = bin(i) -    chkdic = {} -    n_honest = 0  # 正直者の人数をカウント -    flag = False  # 矛盾が生じるかどうか -    for j in range(n): -        if (i >> j) & 1:  # もし正直者なら -            n_honest += 1 -            # saying_l=l[j] -            # a=al[j] -            chkdic[j + 1] = 1 -        else: -            chkdic[j + 1] = 0 -    # chkdicをもとに判定 +    n_honest = 0 +    dic = {} +    flag = True -            saying_l = l[j] +            n_honest += 1 +            dic[j] = 1 +        else: +            dic[j] = 0 +    for j in range(n): +        if (i >> j) & 1: +            temp = info[j] -                saying = saying_l[k] -                if chkdic[saying[0]] != saying[1]: -                    flag = True +                l = temp[k] +                x = l[0] +                y = l[1] +                if dic[x - 1] != y: +                    flag = False -        if flag: +        if not flag: -    if not flag: -        ans = max(ans, n_honest) +    if flag: +        ans = max(n_honest, ans)