def is_consistent(bit, t_tuple):

    mask, tf = t_tuple

    if (bit & mask) == (tf & mask):

        return True

    else:

        return False



n = int(eval(input()))

testimony = [0] * n

for i in range(n):

    mask, tf = 0, 0

    for j in range(int(eval(input()))):

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

        mask += 1 << (x - 1)

        tf += y << (x - 1)

    testimony[i] = (mask, tf)



max_honest = 0

for bit in range(1 << n):

    honest = 0

    all_consistence = True

    for shift in range(n):

        if ((bit >> shift) & 1):

            if is_consistent(bit, testimony[shift]):

                honest += 1

            else:

                all_consistence = False    

    if all_consistence and (max_honest < honest):

        max_honest = honest

print(max_honest)
def is_consistent(bit, testimony):

    all_consistence = True

    for shift in range(n):

        if (bit >> shift) & 1:

            mask, tf = testimony[shift]

            if (bit & mask) != (tf & mask):

                all_consistence = False

    return all_consistence



n = int(eval(input()))

testimony = [0] * n

for i in range(n):

    mask, tf = 0, 0

    for j in range(int(eval(input()))):

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

        mask += 1 << (x - 1)

        tf += y << (x - 1)

    testimony[i] = (mask, tf)



max_honest = 0

for bit in range(1 << n):

    if is_consistent(bit, testimony) and (max_honest < bin(bit).count('1')):

        max_honest = bin(bit).count('1')

print(max_honest)
def is_consistent(bit, t_tuple):
    mask, tf = t_tuple
    if (bit & mask) == (tf & mask):
        return True
    else:
        return False


n = int(eval(input()))
testimony = [0] * n
for i in range(n):
    mask, tf = 0, 0
    for j in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        mask += 1 << (x - 1)
        tf += y << (x - 1)
    testimony[i] = (mask, tf)
max_honest = 0
for bit in range(1 << n):
    honest = 0
    all_consistence = True
    for shift in range(n):
        if (bit >> shift) & 1:
            if is_consistent(bit, testimony[shift]):
                honest += 1
            else:
                all_consistence = False
    if all_consistence and (max_honest < honest):
        max_honest = honest
print(max_honest)

def is_consistent(bit, testimony):
    all_consistence = True
    for shift in range(n):
        if (bit >> shift) & 1:
            mask, tf = testimony[shift]
            if (bit & mask) != (tf & mask):
                all_consistence = False
    return all_consistence


n = int(eval(input()))
testimony = [0] * n
for i in range(n):
    mask, tf = 0, 0
    for j in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        mask += 1 << (x - 1)
        tf += y << (x - 1)
    testimony[i] = (mask, tf)
max_honest = 0
for bit in range(1 << n):
    if is_consistent(bit, testimony) and (max_honest < bin(bit).count("1")):
        max_honest = bin(bit).count("1")
print(max_honest)

-def is_consistent(bit, t_tuple): -    mask, tf = t_tuple -    if (bit & mask) == (tf & mask): -        return True -    else: -        return False +def is_consistent(bit, testimony): +    all_consistence = True +    for shift in range(n): +        if (bit >> shift) & 1: +            mask, tf = testimony[shift] +            if (bit & mask) != (tf & mask): +                all_consistence = False +    return all_consistence -    honest = 0 -    all_consistence = True -    for shift in range(n): -        if (bit >> shift) & 1: -            if is_consistent(bit, testimony[shift]): -                honest += 1 -            else: -                all_consistence = False -    if all_consistence and (max_honest < honest): -        max_honest = honest +    if is_consistent(bit, testimony) and (max_honest < bin(bit).count("1")): +        max_honest = bin(bit).count("1")