import sys

import numpy as np



n = int(sys.stdin.readline().rstrip())

x = []

y = []

for i in range(n):

    a = int(sys.stdin.readline().rstrip())

    xy = [sys.stdin.readline().split() for _ in range(a)]

    if not xy:

        x.append(None)

        y.append(None)

        continue

    xi, yi = np.array(xy, np.int64).T

    x.append(xi-1)

    y.append(yi)



def main():



    ans = 0

    for comb in range(2 ** n):

        cnt = 0

        for i in range(n):

            if not comb >> i & 1:

                continue

            if x[i] is None:

                cnt += 1

                continue

            if np.count_nonzero(comb >> x[i] & 1 ^ y[i]):

                break

            cnt += 1

        else:

            ans = max(ans, cnt)

    return ans

                

if __name__ == '__main__':

    ans = main()

    print(ans)
import sys



n = int(sys.stdin.readline().rstrip())

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

for i in range(n):

    a = int(sys.stdin.readline().rstrip())

    for j in range(a):

        x, y = list(map(int, sys.stdin.readline().split()))

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



def main():

    ans = 0

    for comb in range(2 ** n):

        cnt = 0

        for i in range(n):

            if comb >> i & 1 ^ 1:

                continue

            for x, y in xy[i]:

                if comb >> x & 1 ^ y:

                    break

            else:

                cnt += 1

                continue

            break

        else:

            ans = max(ans, cnt)

    return ans

                

if __name__ == '__main__':

    ans = main()

    print(ans)
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
x = []
y = []
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    xy = [sys.stdin.readline().split() for _ in range(a)]
    if not xy:
        x.append(None)
        y.append(None)
        continue
    xi, yi = np.array(xy, np.int64).T
    x.append(xi - 1)
    y.append(yi)


def main():
    ans = 0
    for comb in range(2**n):
        cnt = 0
        for i in range(n):
            if not comb >> i & 1:
                continue
            if x[i] is None:
                cnt += 1
                continue
            if np.count_nonzero(comb >> x[i] & 1 ^ y[i]):
                break
            cnt += 1
        else:
            ans = max(ans, cnt)
    return ans


if __name__ == "__main__":
    ans = main()
    print(ans)

import sys

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = list(map(int, sys.stdin.readline().split()))
        xy[i].append((x - 1, y))


def main():
    ans = 0
    for comb in range(2**n):
        cnt = 0
        for i in range(n):
            if comb >> i & 1 ^ 1:
                continue
            for x, y in xy[i]:
                if comb >> x & 1 ^ y:
                    break
            else:
                cnt += 1
                continue
            break
        else:
            ans = max(ans, cnt)
    return ans


if __name__ == "__main__":
    ans = main()
    print(ans)

-import numpy as np -x = [] -y = [] +xy = [[] for _ in range(n)] -    xy = [sys.stdin.readline().split() for _ in range(a)] -    if not xy: -        x.append(None) -        y.append(None) -        continue -    xi, yi = np.array(xy, np.int64).T -    x.append(xi - 1) -    y.append(yi) +    for j in range(a): +        x, y = list(map(int, sys.stdin.readline().split())) +        xy[i].append((x - 1, y)) -            if not comb >> i & 1: +            if comb >> i & 1 ^ 1: -            if x[i] is None: +            for x, y in xy[i]: +                if comb >> x & 1 ^ y: +                    break +            else: -            if np.count_nonzero(comb >> x[i] & 1 ^ y[i]): -                break -            cnt += 1 +            break