def is_nth_bit_set(x, n):

    if x & (1 << n):

        return 1

    else:

        return 0





N = int(eval(input()))

comment = {}

for i in range(N):

    A = int(eval(input()))

    comment[i] = []

    for _ in range(A):

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

        x -= 1

        comment[i].append((x, y))



ans = 0

for i in range(2 ** N):

    judge = [None] * N

    flag = True

    for j in range(N):

        honest = is_nth_bit_set(i, j)

        judge[j] = honest



    for j in range(N):

        honest = judge[j]

        if not honest:

            continue

        for x, y in comment[j]:

            if honest:

                if judge[x] == y:

                    continue

                else:

                    flag = False

                    break

    if not flag:

        continue



    tmp = sum(judge)

    if tmp > ans:

        ans = tmp

print(ans)

import sys



sys.setrecursionlimit(10 ** 6)

INF = float("inf")

MOD = 10 ** 9 + 7





def input():

    return sys.stdin.readline().strip()





def is_nth_bit_set(x, n):

    if x & (1 << n):

        return True

    else:

        return False





def main():

    N = int(eval(input()))



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

    for i in range(N):

        A = int(eval(input()))

        for _ in range(A):

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

            x -= 1

            comments[i].append((x, y))



    total = 2 ** N

    ans = 0

    for pattern in range(total):

        flag = True

        tmp = 0

        for i in range(N):

            if is_nth_bit_set(pattern, i):

                tmp += 1

                for x, y in comments[i]:

                    if is_nth_bit_set(pattern, x) == bool(y):

                        continue

                    else:

                        flag = False

                        break

            else:

                continue



            if not flag:

                break



        if flag:

            if tmp > ans:

                ans = tmp



    print(ans)





if __name__ == "__main__":

    main()

def is_nth_bit_set(x, n):
    if x & (1 << n):
        return 1
    else:
        return 0


N = int(eval(input()))
comment = {}
for i in range(N):
    A = int(eval(input()))
    comment[i] = []
    for _ in range(A):
        x, y = list(map(int, input().split()))
        x -= 1
        comment[i].append((x, y))
ans = 0
for i in range(2**N):
    judge = [None] * N
    flag = True
    for j in range(N):
        honest = is_nth_bit_set(i, j)
        judge[j] = honest
    for j in range(N):
        honest = judge[j]
        if not honest:
            continue
        for x, y in comment[j]:
            if honest:
                if judge[x] == y:
                    continue
                else:
                    flag = False
                    break
    if not flag:
        continue
    tmp = sum(judge)
    if tmp > ans:
        ans = tmp
print(ans)

import sys

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().strip()


def is_nth_bit_set(x, n):
    if x & (1 << n):
        return True
    else:
        return False


def main():
    N = int(eval(input()))
    comments = [[] for _ in range(N)]
    for i in range(N):
        A = int(eval(input()))
        for _ in range(A):
            x, y = list(map(int, input().split()))
            x -= 1
            comments[i].append((x, y))
    total = 2**N
    ans = 0
    for pattern in range(total):
        flag = True
        tmp = 0
        for i in range(N):
            if is_nth_bit_set(pattern, i):
                tmp += 1
                for x, y in comments[i]:
                    if is_nth_bit_set(pattern, x) == bool(y):
                        continue
                    else:
                        flag = False
                        break
            else:
                continue
            if not flag:
                break
        if flag:
            if tmp > ans:
                ans = tmp
    print(ans)


if __name__ == "__main__":
    main()

+import sys + +sys.setrecursionlimit(10**6) +INF = float("inf") +MOD = 10**9 + 7 + + +def input(): +    return sys.stdin.readline().strip() + + -        return 1 +        return True -        return 0 +        return False -N = int(eval(input())) -comment = {} -for i in range(N): -    A = int(eval(input())) -    comment[i] = [] -    for _ in range(A): -        x, y = list(map(int, input().split())) -        x -= 1 -        comment[i].append((x, y)) -ans = 0 -for i in range(2**N): -    judge = [None] * N -    flag = True -    for j in range(N): -        honest = is_nth_bit_set(i, j) -        judge[j] = honest -    for j in range(N): -        honest = judge[j] -        if not honest: -            continue -        for x, y in comment[j]: -            if honest: -                if judge[x] == y: -                    continue -                else: -                    flag = False -                    break -    if not flag: -        continue -    tmp = sum(judge) -    if tmp > ans: -        ans = tmp -print(ans) +def main(): +    N = int(eval(input())) +    comments = [[] for _ in range(N)] +    for i in range(N): +        A = int(eval(input())) +        for _ in range(A): +            x, y = list(map(int, input().split())) +            x -= 1 +            comments[i].append((x, y)) +    total = 2**N +    ans = 0 +    for pattern in range(total): +        flag = True +        tmp = 0 +        for i in range(N): +            if is_nth_bit_set(pattern, i): +                tmp += 1 +                for x, y in comments[i]: +                    if is_nth_bit_set(pattern, x) == bool(y): +                        continue +                    else: +                        flag = False +                        break +            else: +                continue +            if not flag: +                break +        if flag: +            if tmp > ans: +                ans = tmp +    print(ans) + + +if __name__ == "__main__": +    main()