def honestcount(i):

    return bin(i).count("1")



def is_honest(i,j):

    return (i>>j)%2 == 1



N = int(eval(input()))



A = [0] * N

shogens=[]



for i in range(N):

    a = int(eval(input()))

    shogen=[]

    for j in range(a):

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

        shogen.append((x-1,y))

    shogens.append(shogen)

# print(shogens)



count=0

for i in range(1<<N):

    is_ok =True

    for j in range(N):

        if not is_honest(i,j):

            continue

        for x,y in shogens[j]:

            if y!=is_honest(i,x): is_ok=False

    if is_ok:

        count=max(count,honestcount(i))

print(count)

def honestcount(i):

    return bin(i).count("1")



def is_honest(i,j):

    return (i>>j)%2 == 1



N = int(eval(input()))



A = [0] * N

shogens=[]



for i in range(N):

    a = int(eval(input()))

    shogen=[]

    for j in range(a):

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

        shogen.append((x-1,y))

    shogens.append(shogen)

# print(shogens)



count=0

for i in range(1<<N):

    is_ok =True

    for j in range(N):

        if not is_honest(i,j):

            continue

        for x,y in shogens[j]:

            if y!=is_honest(i,x):

                is_ok=False

                break

    if is_ok:

        count=max(count,honestcount(i))

print(count)

def honestcount(i):
    return bin(i).count("1")


def is_honest(i, j):
    return (i >> j) % 2 == 1


N = int(eval(input()))
A = [0] * N
shogens = []
for i in range(N):
    a = int(eval(input()))
    shogen = []
    for j in range(a):
        x, y = list(map(int, input().split()))
        shogen.append((x - 1, y))
    shogens.append(shogen)
# print(shogens)
count = 0
for i in range(1 << N):
    is_ok = True
    for j in range(N):
        if not is_honest(i, j):
            continue
        for x, y in shogens[j]:
            if y != is_honest(i, x):
                is_ok = False
    if is_ok:
        count = max(count, honestcount(i))
print(count)

def honestcount(i):
    return bin(i).count("1")


def is_honest(i, j):
    return (i >> j) % 2 == 1


N = int(eval(input()))
A = [0] * N
shogens = []
for i in range(N):
    a = int(eval(input()))
    shogen = []
    for j in range(a):
        x, y = list(map(int, input().split()))
        shogen.append((x - 1, y))
    shogens.append(shogen)
# print(shogens)
count = 0
for i in range(1 << N):
    is_ok = True
    for j in range(N):
        if not is_honest(i, j):
            continue
        for x, y in shogens[j]:
            if y != is_honest(i, x):
                is_ok = False
                break
    if is_ok:
        count = max(count, honestcount(i))
print(count)

+                break