n = int(eval(input()))

a =[]

for _ in range(n):

    m = int(eval(input()))

    a.append([list(map(int, input().split())) for _ in range(m)])

c = 0

for i in range(1 << n):

    Flag = True

    for j in range(n):

        if ((i>>j)&1) == 1:

            for k in a[j]:

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

                    Flag = False

        if Flag == False:break

    else:

        honest = sum([i>>j&1 for j in range(n)])

        c = max(c,honest)

print(c)
n = int(eval(input()))

a = []

for _ in range(n):

    m = int(eval(input()))

    a.append([list(map(int, input().split())) for _ in range(m)])



ans = 0

for i in range(2**n):

    for j in range(n):

        if ((i >> j) & 1) == 1:

            for k,l in a[j]:

                if ((i >> (k-1)) & 1) != l:

                    break

            else:

                continue

            break

    else:

        ans = max(ans,bin(i).count('1'))

print(ans)
n = int(eval(input()))
a = []
for _ in range(n):
    m = int(eval(input()))
    a.append([list(map(int, input().split())) for _ in range(m)])
c = 0
for i in range(1 << n):
    Flag = True
    for j in range(n):
        if ((i >> j) & 1) == 1:
            for k in a[j]:
                if i >> (k[0] - 1) & 1 != k[1]:
                    Flag = False
        if Flag == False:
            break
    else:
        honest = sum([i >> j & 1 for j in range(n)])
        c = max(c, honest)
print(c)

n = int(eval(input()))
a = []
for _ in range(n):
    m = int(eval(input()))
    a.append([list(map(int, input().split())) for _ in range(m)])
ans = 0
for i in range(2**n):
    for j in range(n):
        if ((i >> j) & 1) == 1:
            for k, l in a[j]:
                if ((i >> (k - 1)) & 1) != l:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, bin(i).count("1"))
print(ans)

-c = 0 -for i in range(1 << n): -    Flag = True +ans = 0 +for i in range(2**n): -            for k in a[j]: -                if i >> (k[0] - 1) & 1 != k[1]: -                    Flag = False -        if Flag == False: +            for k, l in a[j]: +                if ((i >> (k - 1)) & 1) != l: +                    break +            else: +                continue -        honest = sum([i >> j & 1 for j in range(n)]) -        c = max(c, honest) -print(c) +        ans = max(ans, bin(i).count("1")) +print(ans)