n = int(eval(input()))

A = []

xy = []

max = 0

for i in range(n):

  a = int(eval(input()))

  A.append(a)

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

for i in range(2**n):

    ls = [0]*n

    check = 0

    for j in range(len(ls)):

        if (i >> j) & 1:

            ls[j] = 1

    for p in range(len(xy)):

      for t in xy[p]:

        if t[1] == 1 and ls[p] == 1:

          if ls[t[0]-1] != 1:

            check = 1

            break

        elif t[1] == 0 and ls[p] == 1:

          if ls[t[0]-1] != 0:

            check = 1

            break

    if check == 0:

      if ls.count(1) > max:

        max = ls.count(1)

print(max)

n = int(eval(input()))

A = []

xy = []

max = 0

for i in range(n):

  a = int(eval(input()))

  A.append(a)

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

for i in range(2**n):

    ls = [0]*n

    check = 0

    for j in range(len(ls)):

        if (i >> j) & 1:

            ls[j] = 1

    for p in range(len(xy)):

      for t in xy[p]:

        if t[1] == 1 and ls[p] == 1:

          if ls[t[0]-1] != 1:

            check = 1

            break

        elif t[1] == 0 and ls[p] == 1:

          if ls[t[0]-1] != 0:

            check = 1

            break

      else:

        continue

      break

    if check == 0:

      if ls.count(1) > max:

        max = ls.count(1)

print(max)

n = int(eval(input()))
A = []
xy = []
max = 0
for i in range(n):
    a = int(eval(input()))
    A.append(a)
    xy.append([list(map(int, input().split())) for i in range(a)])
for i in range(2**n):
    ls = [0] * n
    check = 0
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = 1
    for p in range(len(xy)):
        for t in xy[p]:
            if t[1] == 1 and ls[p] == 1:
                if ls[t[0] - 1] != 1:
                    check = 1
                    break
            elif t[1] == 0 and ls[p] == 1:
                if ls[t[0] - 1] != 0:
                    check = 1
                    break
    if check == 0:
        if ls.count(1) > max:
            max = ls.count(1)
print(max)

n = int(eval(input()))
A = []
xy = []
max = 0
for i in range(n):
    a = int(eval(input()))
    A.append(a)
    xy.append([list(map(int, input().split())) for i in range(a)])
for i in range(2**n):
    ls = [0] * n
    check = 0
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = 1
    for p in range(len(xy)):
        for t in xy[p]:
            if t[1] == 1 and ls[p] == 1:
                if ls[t[0] - 1] != 1:
                    check = 1
                    break
            elif t[1] == 0 and ls[p] == 1:
                if ls[t[0] - 1] != 0:
                    check = 1
                    break
        else:
            continue
        break
    if check == 0:
        if ls.count(1) > max:
            max = ls.count(1)
print(max)

+        else: +            continue +        break