Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [[-1]*n for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int, input().split())
        lst[i][x-1] = y

item = [i for i in range(2**n)]
def bitka(n):
    honest = []
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            honest.append(item[j])  # フラグが立っていたら bag に果物を詰める
    return honest

def check(honest, lst):
    for i in honest:
        for j in range(n):
            if lst[i][j]==1:
                if j not in honest:
                    return False
            elif lst[i][j]==0:
                if j in honest:
                    return False
    return True

ans = 0
for i in range(2**n):
    if check(bitka(i),lst)==True:
        ans = max(ans, len(bitka(i)))
print(ans)


Fixed submission:
n = int(input())
ms = []
say = []
for i in range(n):
    m = int(input())
    ms.append(m)
    say.append([])
    for j in range(m):
        p,q = list(map(int, input().split()))
        say[i].append([p,q])

# ms =  [2, 2, 2]
# say = [[[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

ans = 0
for i in range(2**n):
    flag = 1
    nowbit = bitlist(i,n)
    for j in range(n):
        for k in range(ms[j]):
            if nowbit[j]==1:
                if say[j][k][1] != nowbit[say[j][k][0]-1]:
                    flag = 0
    if flag == 1:
        ans = max(ans, sum(nowbit))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [[-1]*n for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int, input().split())
        lst[i][x-1] = y

item = [i for i in range(2**n)]
def bitka(n):
    honest = []
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            honest.append(item[j])  # フラグが立っていたら bag に果物を詰める
    return honest

def check(honest, lst):
    for i in honest:
        for j in range(n):
            if lst[i][j]==1:
                if j not in honest:
                    return False
            elif lst[i][j]==0:
                if j in honest:
                    return False
    return True

ans = 0
for i in range(2**n):
    if check(bitka(i),lst)==True:
        ans = max(ans, len(bitka(i)))
print(ans)


Fixed submission:
n = int(input())
ms = []
say = []
for i in range(n):
    m = int(input())
    ms.append(m)
    say.append([])
    for j in range(m):
        p,q = list(map(int, input().split()))
        say[i].append([p,q])

# ms =  [2, 2, 2]
# say = [[[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

ans = 0
for i in range(2**n):
    flag = 1
    nowbit = bitlist(i,n)
    for j in range(n):
        for k in range(ms[j]):
            if nowbit[j]==1:
                if say[j][k][1] != nowbit[say[j][k][0]-1]:
                    flag = 0
    if flag == 1:
        ans = max(ans, sum(nowbit))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [[-1]*n for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int, input().split())
        lst[i][x-1] = y

item = [i for i in range(2**n)]
def bitka(n):
    honest = []
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            honest.append(item[j])  # フラグが立っていたら bag に果物を詰める
    return honest

def check(honest, lst):
    for i in honest:
        for j in range(n):
            if lst[i][j]==1 and (j not in honest):
                return False
            elif lst[i][j]==0 and (j in honest):
                return False
    return True

ans = 0
for i in range(2**n):
    if check(bitka(i),lst)==True:
        ans = max(ans, len(bitka(i)))
print(ans)


Fixed submission:
n = int(input())
ms = []
say = []
for i in range(n):
    m = int(input())
    ms.append(m)
    say.append([])
    for j in range(m):
        p,q = list(map(int, input().split()))
        say[i].append([p,q])

# ms =  [2, 2, 2]
# say = [[[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

ans = 0
for i in range(2**n):
    flag = 1
    nowbit = bitlist(i,n)
    for j in range(n):
        for k in range(ms[j]):
            if nowbit[j]==1:
                if say[j][k][1] != nowbit[say[j][k][0]-1]:
                    flag = 0
    if flag == 1:
        ans = max(ans, sum(nowbit))

print(ans)