import sys

import numpy as np



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

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

for i in range(n):

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

    for _ in range(a):

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

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



def main():

    comb = (np.arange(2 ** n).reshape(-1, 1) >> np.arange(n) & 1).astype(np.bool)

    for i in range(n):

        for x, y in xy[i]:

            bl = ~comb[:, i] | (comb[:, x] == np.bool(y))

            comb = comb[bl] # ありえる組み合わせだけを残す

    '''

    ~comb[:, i]:= (i番目がUnkindと仮定したとき、)i番目をUnkind(False)としている組み合わせを残す

    (comb[:, x] == np.bool(y)):= (i番目がHonestと仮定したとき、)i番目の証言が矛盾しない組み合わせを残す

    '''

    

    ans = np.amax(np.sum(comb, axis=1))

    return ans



if __name__ == '__main__':

    ans = main()

    print(ans)
import sys

import numpy as np 



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

graph = [None] * n

for i in range(n):

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

    if not a: continue

    graph[i] = np.array([sys.stdin.readline().split() for _ in range(a)], dtype=np.int16).T



def main():

    comb = (np.arange(1 << n)[:, None] >> np.arange(n) & 1).astype(np.bool)

    ok = np.full(1 << n, True, dtype=np.bool)

    for i in range(n):

        if graph[i] is None: continue

        x, y = graph[i]

        ok &= ~comb[:, i] | np.all(comb[:, x-1] == y.astype(np.bool), axis=1)



    print((np.amax(comb[ok].sum(axis=1))))



if __name__ ==  '__main__':

    main()
import sys
import numpy as np

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


def main():
    comb = (np.arange(2**n).reshape(-1, 1) >> np.arange(n) & 1).astype(np.bool)
    for i in range(n):
        for x, y in xy[i]:
            bl = ~comb[:, i] | (comb[:, x] == np.bool(y))
            comb = comb[bl]  # ありえる組み合わせだけを残す
    """
    ~comb[:, i]:= (i番目がUnkindと仮定したとき、)i番目をUnkind(False)としている組み合わせを残す
    (comb[:, x] == np.bool(y)):= (i番目がHonestと仮定したとき、)i番目の証言が矛盾しない組み合わせを残す
    """
    ans = np.amax(np.sum(comb, axis=1))
    return ans


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

import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
graph = [None] * n
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    if not a:
        continue
    graph[i] = np.array(
        [sys.stdin.readline().split() for _ in range(a)], dtype=np.int16
    ).T


def main():
    comb = (np.arange(1 << n)[:, None] >> np.arange(n) & 1).astype(np.bool)
    ok = np.full(1 << n, True, dtype=np.bool)
    for i in range(n):
        if graph[i] is None:
            continue
        x, y = graph[i]
        ok &= ~comb[:, i] | np.all(comb[:, x - 1] == y.astype(np.bool), axis=1)
    print((np.amax(comb[ok].sum(axis=1))))


if __name__ == "__main__":
    main()

-xy = [[] for _ in range(n)] +graph = [None] * n -    for _ in range(a): -        x, y = list(map(int, sys.stdin.readline().split())) -        xy[i].append((x - 1, y)) +    if not a: +        continue +    graph[i] = np.array( +        [sys.stdin.readline().split() for _ in range(a)], dtype=np.int16 +    ).T -    comb = (np.arange(2**n).reshape(-1, 1) >> np.arange(n) & 1).astype(np.bool) +    comb = (np.arange(1 << n)[:, None] >> np.arange(n) & 1).astype(np.bool) +    ok = np.full(1 << n, True, dtype=np.bool) -        for x, y in xy[i]: -            bl = ~comb[:, i] | (comb[:, x] == np.bool(y)) -            comb = comb[bl]  # ありえる組み合わせだけを残す -    """ -    ~comb[:, i]:= (i番目がUnkindと仮定したとき、)i番目をUnkind(False)としている組み合わせを残す -    (comb[:, x] == np.bool(y)):= (i番目がHonestと仮定したとき、)i番目の証言が矛盾しない組み合わせを残す -    """ -    ans = np.amax(np.sum(comb, axis=1)) -    return ans +        if graph[i] is None: +            continue +        x, y = graph[i] +        ok &= ~comb[:, i] | np.all(comb[:, x - 1] == y.astype(np.bool), axis=1) +    print((np.amax(comb[ok].sum(axis=1)))) -    ans = main() -    print(ans) +    main()