N = int(eval(input()))

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

for i in range(N):

  A_i = int(eval(input()))

  for j in range(A_i):

    a[i].append(list(map(int, input().split())))

 

max_honest = 0

for i in range(2**N):

  contradiction = False

  honest_p = []

  unkind_p = []

  doubt_honest_p = []

  doubt_unkind_p = []

  length = len(format(2**N-1, "b"))

  bin_num = format(i, "b").zfill(length)

  for j in range(length):

    if (i >> j) & 1:

      if not j+1 in honest_p:

      	honest_p.append(j+1)

      if not j+1 in doubt_honest_p:

      	doubt_honest_p.append(j+1)

      for k in a[j]:

        p = k[0]

        t = k[1]

        if t:

          if not p in honest_p:

          	honest_p.append(p)

        else:

          if not p in unkind_p: 

          	unkind_p.append(p)

    else:

      if not j+1 in unkind_p:

        unkind_p.append(j+1)

      if not j+1 in doubt_unkind_p:

      	doubt_unkind_p.append(j+1)

  if len(list(set(honest_p) & set(unkind_p))) != 0:

    contradiction = True

  if not contradiction and max_honest <= len(doubt_honest_p):

    max_honest = len(doubt_honest_p)

    

print(max_honest)
N = int(eval(input()))

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

for i in range(N):

  A_i = int(eval(input()))

  for j in range(A_i):

    a[i].append(list(map(int, input().split())))



max_person = 0

for i in range(2**N):

  judge = True

  bin_num = bin(i)

  times = 0

  end = False

  for j in reversed(bin_num):

    if j == "b":

      break

    if j == "1":

      for k in a[times]:

        if ((i >> k[0]-1) & 1) != k[1]:

          judge = False

    times += 1

  true_person = bin_num.count("1")

  if judge == True:

    max_person = max(max_person, true_person)

print(max_person)
N = int(eval(input()))
a = [[] for _ in range(N)]
for i in range(N):
    A_i = int(eval(input()))
    for j in range(A_i):
        a[i].append(list(map(int, input().split())))
max_honest = 0
for i in range(2**N):
    contradiction = False
    honest_p = []
    unkind_p = []
    doubt_honest_p = []
    doubt_unkind_p = []
    length = len(format(2**N - 1, "b"))
    bin_num = format(i, "b").zfill(length)
    for j in range(length):
        if (i >> j) & 1:
            if not j + 1 in honest_p:
                honest_p.append(j + 1)
            if not j + 1 in doubt_honest_p:
                doubt_honest_p.append(j + 1)
            for k in a[j]:
                p = k[0]
                t = k[1]
                if t:
                    if not p in honest_p:
                        honest_p.append(p)
                else:
                    if not p in unkind_p:
                        unkind_p.append(p)
        else:
            if not j + 1 in unkind_p:
                unkind_p.append(j + 1)
            if not j + 1 in doubt_unkind_p:
                doubt_unkind_p.append(j + 1)
    if len(list(set(honest_p) & set(unkind_p))) != 0:
        contradiction = True
    if not contradiction and max_honest <= len(doubt_honest_p):
        max_honest = len(doubt_honest_p)
print(max_honest)

N = int(eval(input()))
a = [[] for _ in range(N)]
for i in range(N):
    A_i = int(eval(input()))
    for j in range(A_i):
        a[i].append(list(map(int, input().split())))
max_person = 0
for i in range(2**N):
    judge = True
    bin_num = bin(i)
    times = 0
    end = False
    for j in reversed(bin_num):
        if j == "b":
            break
        if j == "1":
            for k in a[times]:
                if ((i >> k[0] - 1) & 1) != k[1]:
                    judge = False
        times += 1
    true_person = bin_num.count("1")
    if judge == True:
        max_person = max(max_person, true_person)
print(max_person)

-max_honest = 0 +max_person = 0 -    contradiction = False -    honest_p = [] -    unkind_p = [] -    doubt_honest_p = [] -    doubt_unkind_p = [] -    length = len(format(2**N - 1, "b")) -    bin_num = format(i, "b").zfill(length) -    for j in range(length): -        if (i >> j) & 1: -            if not j + 1 in honest_p: -                honest_p.append(j + 1) -            if not j + 1 in doubt_honest_p: -                doubt_honest_p.append(j + 1) -            for k in a[j]: -                p = k[0] -                t = k[1] -                if t: -                    if not p in honest_p: -                        honest_p.append(p) -                else: -                    if not p in unkind_p: -                        unkind_p.append(p) -        else: -            if not j + 1 in unkind_p: -                unkind_p.append(j + 1) -            if not j + 1 in doubt_unkind_p: -                doubt_unkind_p.append(j + 1) -    if len(list(set(honest_p) & set(unkind_p))) != 0: -        contradiction = True -    if not contradiction and max_honest <= len(doubt_honest_p): -        max_honest = len(doubt_honest_p) -print(max_honest) +    judge = True +    bin_num = bin(i) +    times = 0 +    end = False +    for j in reversed(bin_num): +        if j == "b": +            break +        if j == "1": +            for k in a[times]: +                if ((i >> k[0] - 1) & 1) != k[1]: +                    judge = False +        times += 1 +    true_person = bin_num.count("1") +    if judge == True: +        max_person = max(max_person, true_person) +print(max_person)