def counter(x):

    if x == 0:

        return 0

    return counter(x >> 1) + (x & 1)





N = int(eval(input()))

A = [0 for i in range(20)]

x = [[0 for i in range(20)] for j in range(20)]

y = [[0 for i in range(20)] for j in range(20)]



for i in range(1, N + 1):

    A[i] = int(eval(input()))

    for j in range(1, A[i] + 1):

        x[i][j], y[i][j] = list(map(int, input().split()))



# 2^N 通りをbit全探索

# kが正直者 = 2進数表記のk-1桁目が1 (1 <= k <= N)

ans = 0

for bits in range(1, 1 << N):

    ok = True

    for i in range(1, N + 1):

        # 不親切な人の意見は無視

        if not ((bits >> (i - 1)) & 1):

            continue

        for j in range(1, A[i] + 1):

            # x_ij が正直者であることが偽であれば False

            if ((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]:

                ok = False

    if ok:

        ans = max(ans, counter(bits))



print(ans)

def counter(x):

    if x == 0:

        return 0

    return counter(x >> 1) + (x & 1)





N = int(eval(input()))

A = [0 for i in range(20)]

x = [[0 for i in range(20)] for j in range(20)]

y = [[0 for i in range(20)] for j in range(20)]



for i in range(1, N + 1):

    A[i] = int(eval(input()))

    for j in range(1, A[i] + 1):

        x[i][j], y[i][j] = list(map(int, input().split()))



# 2^N 通りをbit全探索

# kが正直者 = 2進数表記のk-1桁目が1 (1 <= k <= N)

ans = 0

for bits in range(1, 1 << N):

    ok = True

    for i in range(1, N + 1):

        # 不親切な人の証言は無視

        if ((bits >> (i - 1)) & 1) == 0:

            continue

        for j in range(1, A[i] + 1):

            # x_ij が正直者であることが偽であれば False

            if ((bits >> (x[i][j] - 1)) & 1) != y[i][j]:

                ok = False

    if ok:

        ans = max(ans, counter(bits))



print(ans)

def counter(x):
    if x == 0:
        return 0
    return counter(x >> 1) + (x & 1)


N = int(eval(input()))
A = [0 for i in range(20)]
x = [[0 for i in range(20)] for j in range(20)]
y = [[0 for i in range(20)] for j in range(20)]
for i in range(1, N + 1):
    A[i] = int(eval(input()))
    for j in range(1, A[i] + 1):
        x[i][j], y[i][j] = list(map(int, input().split()))
# 2^N 通りをbit全探索
# kが正直者 = 2進数表記のk-1桁目が1 (1 <= k <= N)
ans = 0
for bits in range(1, 1 << N):
    ok = True
    for i in range(1, N + 1):
        # 不親切な人の意見は無視
        if not ((bits >> (i - 1)) & 1):
            continue
        for j in range(1, A[i] + 1):
            # x_ij が正直者であることが偽であれば False
            if ((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]:
                ok = False
    if ok:
        ans = max(ans, counter(bits))
print(ans)

def counter(x):
    if x == 0:
        return 0
    return counter(x >> 1) + (x & 1)


N = int(eval(input()))
A = [0 for i in range(20)]
x = [[0 for i in range(20)] for j in range(20)]
y = [[0 for i in range(20)] for j in range(20)]
for i in range(1, N + 1):
    A[i] = int(eval(input()))
    for j in range(1, A[i] + 1):
        x[i][j], y[i][j] = list(map(int, input().split()))
# 2^N 通りをbit全探索
# kが正直者 = 2進数表記のk-1桁目が1 (1 <= k <= N)
ans = 0
for bits in range(1, 1 << N):
    ok = True
    for i in range(1, N + 1):
        # 不親切な人の証言は無視
        if ((bits >> (i - 1)) & 1) == 0:
            continue
        for j in range(1, A[i] + 1):
            # x_ij が正直者であることが偽であれば False
            if ((bits >> (x[i][j] - 1)) & 1) != y[i][j]:
                ok = False
    if ok:
        ans = max(ans, counter(bits))
print(ans)

-        # 不親切な人の意見は無視 -        if not ((bits >> (i - 1)) & 1): +        # 不親切な人の証言は無視 +        if ((bits >> (i - 1)) & 1) == 0: -            if ((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]: +            if ((bits >> (x[i][j] - 1)) & 1) != y[i][j]: