import sys

input = sys.stdin.readline



N = int(eval(input()))

STATE = [[]]*N

for i in range(N):

    a = int(eval(input()))

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



def main():

    ans = 0

    for i in range(1<<N):

        ans = max(ans, detect(i))

    print(ans)



def detect(i):

    ONT = 0

    for j in range(N):

        if  not (i & 1<<j):

            continue

        ONT += 1

        for x, y in STATE[j]:



            if (y==0) ^ (i>>(x-1) & 1) == 0:

                return 0

    return ONT



if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline

def main():

    N  = int(eval(input()))

    R = [[] for i in range(N)]

    for i in range(N):

        A = int(eval(input()))

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

    ans = 0

    for i in range(1<<N):

        CNT = 0

        for j in range(N):

            if not (i>>j & 1):

                continue

            CNT += 1

            for x, y in R[j]:

                if y == 1 and (i>>(x-1) & 1):

                    continue

                elif y == 0 and (not (i>>(x-1) & 1)):

                    continue

                else:

                    CNT = 0

                    break

            else:

                continue

            break



        ans = max(ans, CNT)

    print(ans)



if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline
N = int(eval(input()))
STATE = [[]] * N
for i in range(N):
    a = int(eval(input()))
    STATE[i] = [list(map(int, input().split())) for i in range(a)]


def main():
    ans = 0
    for i in range(1 << N):
        ans = max(ans, detect(i))
    print(ans)


def detect(i):
    ONT = 0
    for j in range(N):
        if not (i & 1 << j):
            continue
        ONT += 1
        for x, y in STATE[j]:
            if (y == 0) ^ (i >> (x - 1) & 1) == 0:
                return 0
    return ONT


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    R = [[] for i in range(N)]
    for i in range(N):
        A = int(eval(input()))
        R[i] = [list(map(int, input().split())) for i in range(A)]
    ans = 0
    for i in range(1 << N):
        CNT = 0
        for j in range(N):
            if not (i >> j & 1):
                continue
            CNT += 1
            for x, y in R[j]:
                if y == 1 and (i >> (x - 1) & 1):
                    continue
                elif y == 0 and (not (i >> (x - 1) & 1)):
                    continue
                else:
                    CNT = 0
                    break
            else:
                continue
            break
        ans = max(ans, CNT)
    print(ans)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -STATE = [[]] * N -for i in range(N): -    a = int(eval(input())) -    STATE[i] = [list(map(int, input().split())) for i in range(a)] +    N = int(eval(input())) +    R = [[] for i in range(N)] +    for i in range(N): +        A = int(eval(input())) +        R[i] = [list(map(int, input().split())) for i in range(A)] -        ans = max(ans, detect(i)) +        CNT = 0 +        for j in range(N): +            if not (i >> j & 1): +                continue +            CNT += 1 +            for x, y in R[j]: +                if y == 1 and (i >> (x - 1) & 1): +                    continue +                elif y == 0 and (not (i >> (x - 1) & 1)): +                    continue +                else: +                    CNT = 0 +                    break +            else: +                continue +            break +        ans = max(ans, CNT) - - -def detect(i): -    ONT = 0 -    for j in range(N): -        if not (i & 1 << j): -            continue -        ONT += 1 -        for x, y in STATE[j]: -            if (y == 0) ^ (i >> (x - 1) & 1) == 0: -                return 0 -    return ONT