# coding: utf-8





def solve(*args: str) -> str:

    n = int(args[0])

    T = [[None]*n for _ in range(n)]



    try:

        it = iter(args[1:])

        a = next(it)

        i = 1

        while a:

            for _ in range(int(a)):

                x, y = list(map(int, next(it).split()))

                T[i-1][x-1] = y == 1

            a = next(it)

            i += 1

    except StopIteration:

        pass



    ret = 0

    for hypo in range(2**n):

        consistent = True

        truth = [None]*n

        count = 0

        i = 0

        while consistent and i < n:

            if (hypo >> i) & 1:

                count += 1

                j = 0

                while consistent and j < n:

                    t = T[i][j]

                    if t is not None:

                        if truth[j] is None:

                            truth[j] = t

                        elif truth[j] != t:

                            consistent = False



                        consistent = (hypo >> j) & 1 == t

                    j += 1

            i += 1



        if consistent:

            ret = max(ret, count)



    return str(ret)





if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8





def solve(*args: str) -> str:

    n = int(args[0])

    XY = [[] for _ in range(n)]



    try:

        it = iter(args[1:])

        a = next(it)

        i = 0

        while a:

            for _ in range(int(a)):

                x, y = list(map(int, next(it).split()))

                XY[i].append((x-1, y == 1))

            a = next(it)

            i += 1

    except StopIteration:

        pass



    ret = 0

    for hypo in range(2**n):

        consistent = True

        truth = [None]*n

        count = 0

        i = 0

        while consistent and i < n:

            if (hypo >> i) & 1:

                count += 1

                for x, y in XY[i]:

                    if truth[x] is None:

                        truth[x] = y

                    elif truth[x] != y:

                        consistent = False



                    consistent &= (hypo >> x) & 1 == y

            i += 1



        if consistent:

            ret = max(ret, count)



    return str(ret)





if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    n = int(args[0])
    T = [[None] * n for _ in range(n)]
    try:
        it = iter(args[1:])
        a = next(it)
        i = 1
        while a:
            for _ in range(int(a)):
                x, y = list(map(int, next(it).split()))
                T[i - 1][x - 1] = y == 1
            a = next(it)
            i += 1
    except StopIteration:
        pass
    ret = 0
    for hypo in range(2**n):
        consistent = True
        truth = [None] * n
        count = 0
        i = 0
        while consistent and i < n:
            if (hypo >> i) & 1:
                count += 1
                j = 0
                while consistent and j < n:
                    t = T[i][j]
                    if t is not None:
                        if truth[j] is None:
                            truth[j] = t
                        elif truth[j] != t:
                            consistent = False
                        consistent = (hypo >> j) & 1 == t
                    j += 1
            i += 1
        if consistent:
            ret = max(ret, count)
    return str(ret)


if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    n = int(args[0])
    XY = [[] for _ in range(n)]
    try:
        it = iter(args[1:])
        a = next(it)
        i = 0
        while a:
            for _ in range(int(a)):
                x, y = list(map(int, next(it).split()))
                XY[i].append((x - 1, y == 1))
            a = next(it)
            i += 1
    except StopIteration:
        pass
    ret = 0
    for hypo in range(2**n):
        consistent = True
        truth = [None] * n
        count = 0
        i = 0
        while consistent and i < n:
            if (hypo >> i) & 1:
                count += 1
                for x, y in XY[i]:
                    if truth[x] is None:
                        truth[x] = y
                    elif truth[x] != y:
                        consistent = False
                    consistent &= (hypo >> x) & 1 == y
            i += 1
        if consistent:
            ret = max(ret, count)
    return str(ret)


if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

-    T = [[None] * n for _ in range(n)] +    XY = [[] for _ in range(n)] -        i = 1 +        i = 0 -                T[i - 1][x - 1] = y == 1 +                XY[i].append((x - 1, y == 1)) -                j = 0 -                while consistent and j < n: -                    t = T[i][j] -                    if t is not None: -                        if truth[j] is None: -                            truth[j] = t -                        elif truth[j] != t: -                            consistent = False -                        consistent = (hypo >> j) & 1 == t -                    j += 1 +                for x, y in XY[i]: +                    if truth[x] is None: +                        truth[x] = y +                    elif truth[x] != y: +                        consistent = False +                    consistent &= (hypo >> x) & 1 == y