CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
X = [[] for _ in range(n)]
for i in range(n):
    a = int(eval(input()))
    for j in range(a):
        x, y = list(map(int, input().split()))
        x = x-1
        X[i].append((x, y))

ans = 0
for i in range(2**n):
    cnt = 0
    temp = [-1]*n
    for j in range(n):
        if (i >> j) & 1:
            cnt += 1
            temp[j] = 1
        else:
            temp[j] = 0
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            for x, y in X[j]:
                if temp[x] != y:
                    flag = False
    if flag:
        ans = max(ans, cnt)
print(ans)


# Optimized solution
n = int(eval(input()))

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

for i in range(n):
    a = int(eval(input()))
    for j in range(a):
        x, y = list(map(int, input().split()))
        x -= 1
        g[i].append((x, y))

ans = 0
for i in range(2**n):
    temp = [-1]*n
    for j in range(n):
        if (i >> j) & 1:
            temp[j] = 1
        else:
            temp[j] = 0
    flag = True
    for j in range(n):
        if temp[j] == 1:
            for x, y in g[j]:
                if temp[x] != y:
                    flag = False
    if flag:
        ans = max(ans, sum(temp))
print(ans)
# Original solution
n = int(eval(input()))
t = [[] for _ in range(n)]
s = [[] for _ in range(n)]

for i in range(n):
    a = int(eval(input()))
    for j in range(a):
        x, y = list(map(int, input().split()))
        if y == 1:
            t[i].append(x - 1)
        else:
            s[i].append(x - 1)
res = 0
for k in range(pow(2, n)):
    judge = True
    cnt = 0
    for i in range(n):
        if (k >> i) & 1 == 1:
            for e in t[i]:
                if (k >> e) & 1 == 0:
                    judge = False
            for e in s[i]:
                if (k >> e) & 1 == 1:
                    judge = False
            cnt += 1
    if judge:
        res = max(res, cnt)

print(res)

# Optimized solution
import itertools as it

n = int(eval(input()))
lis = [[] for _ in range(n)]
val = list(it.product([0, 1], repeat=n))

for i in range(n):
    for j in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        x = x - 1
        lis[i].append((x, y))


def honesty(k, lis, n):
    for i in range(n):
        if k[i] == 1:
            for l, m in lis[i]:
                if k[l] != m:
                    return False
    return True


res = 0
for k in val:
    if honesty(k, lis, n):
        res = max(res, sum(k))
print(res)
# Original solution
#!/usr/bin/env python3
#ABC147 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 0
lst = [[] for _ in range(n)]
for i in range(n):
    a = I()
    for j in range(a):
        x,y = LI()
        lst[i].append((x-1,y))
for i in range(2**n):
    b = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            b[j] = 1
    flg = True
    for j in range(n):
        if b[j] == 0:
            continue
        for k,l in lst[j]:
            if l == 0:
                if b[k] == 1:
                    flg = False
                    break
            else:
                if b[k] == 0:
                    flg = False
                    break
        if not flg:
            break
    else:
        ans = max(ans,sum(b))
print(ans)
        
    

# Optimized solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 0
info = [[] for _ in range(n)]
for i in range(n):
    a = I()
    for _ in range(a):
        x, y = LI()
        info[i].append((x-1, y))

for i in range(1, 1 << n):
    ret = 0
    for j in range(n):
        if i >> j & 1:
            ret += 1
            for x, y in info[j]:
                if y == 0 and i >> x & 1:
                    break
                elif y == 1 and not i >> x & 1: 
                    break
            else:
                continue
            break
    else:
        ans = max(ans, ret)
print(ans)
# Original solution
from itertools import product as pro

n = int(eval(input()))
xy = []
for i in range(n):
    a_i = int(eval(input()))
    xy.append([tuple(map(int, input().split())) for _ in range(a_i)])

ans = 0
for l in pro([0, 1], repeat=n):
    for i, t in enumerate(l):
        if t == 1:
            if not all(l[x-1] == y for x, y in xy[i]):
                break
    else:
        ans = max(ans, sum(l))

print(ans)

# Optimized solution
from itertools import product

n = int(eval(input()))
xy = []
for _ in range(n):
    a = int(eval(input()))
    tmp = [list(map(int, input().split())) for _ in range(a)]
    xy.append(tmp)

ans = 0
for bit in product([0, 1], repeat=n):
    for i, liar in enumerate(bit):
        if liar and any(bit[x - 1] != y for x, y in xy[i]):
            break
    else:
        ans = max(ans, sum(bit))
print(ans)
# Original solution
n=int(eval(input()))
a=[]
for i in range(n):
  m=int(eval(input()))
  a.append([])
  for i in range(m):
    a[-1].append(list(map(int,input().split())))
ans=0
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  f=True
  for j,k in enumerate(a):
    for x,y in k:
      if s[x-1]!=str(y) and s[j]=="1":f=False
  if f:ans=max(ans,s.count("1"))
print(ans)

# Optimized solution
n=int(eval(input()))
xy=[[]for _ in range(n)]
for i in range(n):
  for j in range(int(eval(input()))):
    xy[i].append(list(map(int,input().split())))
ans=0
for i in range(1,1<<n):
  syojiki=[(i&(1<<j)!=0)+0 for j in range(n)]
  flag=True
  for j in range(n):
    for x,y in xy[j]:
      if syojiki[x-1]!=y and syojiki[j]==1:flag=False
  if flag:
    ans=max(ans,syojiki.count(1))
print(ans)
# Original solution
import sys
input = sys.stdin.readline

def main():
    n = int(eval(input()))
    remarks = [[]] * n
    max_v = 0

    for i in range(n):
        a = int(eval(input()))
        remarks[i] = [tuple(map(int, input().split())) for _ in range(a)]

    for i in range(2 ** n):
        i_bin = format(i, 'b').zfill(n)
        if i_bin.count('1') <= max_v:
            continue

        is_true = True
        for j in range(n):
            if i_bin[j] == '1':
                for k in remarks[j]:
                    if int(i_bin[k[0]-1]) != k[1]:
                        is_true = False
                        break
                if is_true == False:
                    break
        if is_true:
            max_v = max(max_v, i_bin.count('1'))
    print(max_v)

if __name__ == '__main__':
    main()


# Optimized solution
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(eval(input()))
    said = [[]] * n
    for i in range(n):
        said[i] = [list(map(int, input().split())) for _ in range(int(eval(input())))]

    ans = 0
    n_bit = '0' + str(n) + 'b'
    for i in range(2 ** n):
        i_bin = format(i, n_bit)
        i_bin_c = i_bin.count('1')
        if i_bin_c <= ans:
            continue

        isTrue = True
        for j in range(n):
            if i_bin[j] == '0':
                continue
            for k in said[j]:
                if int(i_bin[k[0]-1]) != k[1]:
                    isTrue = False
                    break
            if not isTrue:
                break
        if isTrue:
            ans = i_bin_c
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
from collections import defaultdict


def is_testimony_correct(hypothesis, testimony):
    # 証言の対象者が仮説上、正直者となっているかを検証。
    for target, is_honest in list(testimony.items()):
        if int(hypothesis[target]) == is_honest:
            continue
        return False
    return True


def is_hypothesis_correct(hypothesis, testimony_dict):
    for witness_num, testimony in list(testimony_dict.items()):
        # 仮説上の正直者の証言だけ検証する
        if hypothesis[witness_num] == "1":
            # 証言を検証
            if is_testimony_correct(hypothesis, testimony):
                continue
            else:
                # 証言に誤りがある場合、Falseで抜ける
                return False
    return True


def main():
    N = int(eval(input()))
    testimony_dict = defaultdict(dict)

    # 証人ごとに証言をdictで保存
    for witness_num in range(N):
        for j in range(int(eval(input()))):
            target, is_honest = list(map(int, input().split()))
            testimony_dict[witness_num][target - 1] = is_honest

    # 仮説を検証  e.g.'010010' 正直者が2人 (witness_num =1, 4)
    max_count = 0
    for i in range(1, 2**N):
        # 仮説を01で表現
        hypothesis = format(i, 'b').zfill(N)
        # 仮説が正しい場合のみ、正直者の数でmax_countを更新
        if is_hypothesis_correct(hypothesis, testimony_dict):
            max_count = max(max_count, hypothesis.count(str("1")))
    print(max_count)


if __name__ == '__main__':
    main()


# Optimized solution
from collections import defaultdict


def is_testimony_correct(hypothesis, testimony):
    # 証言の対象者が仮説上、正直者となっているかを検証。
    for target, is_honest in list(testimony.items()):
        if int(hypothesis[target]) == is_honest:
            continue
        return False
    return True


def is_hypothesis_correct(hypothesis, testimony_dict):
    for witness_num, testimony in list(testimony_dict.items()):
        # 仮説上の正直者の証言だけ検証する
        if hypothesis[witness_num] == "1":
            # 証言を検証
            if is_testimony_correct(hypothesis, testimony):
                continue
            else:
                # 証言に誤りがある場合、Falseで抜ける
                return False
    return True


def main():
    N = int(eval(input()))
    testimony_dict = defaultdict(dict)

    # 証人ごとに証言をdictで保存
    for witness_num in range(N):
        for _ in range(int(eval(input()))):
            target, is_honest = list(map(int, input().split()))
            testimony_dict[witness_num][target - 1] = is_honest

    # 仮説を検証  e.g.'010010' 正直者が2人 (witness_num =1, 4)
    max_count = 0
    for i in range(1, 2**N):
        # 仮説を01で表現
        hypothesis = format(i, 'b').zfill(N)
        # 仮説が正しい場合のみ、正直者の数でmax_countを更新
        if is_hypothesis_correct(hypothesis, testimony_dict):
            max_count = max(max_count, hypothesis.count(str("1")))
    print(max_count)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))

lst = [[] for _ in range(N)]
for i in range(N):
    A = int(eval(input()))
    for _ in range(A):
        x, y = list(map(int, input().split()))
        lst[i].append([x - 1, y])

ans = 0
for i in range(2 ** N):
    check = [-1] * N #1:正直者、0:不親切
    count = 0 #カウント用
    flag = True
    for j in range(N):
        if (i >> j) & 1: #正直者のとき
            if check[j] == 0: #矛盾しているとき
                flag = False
                break
            else:
                check[j] = 1

            # count += 1

            for x, y in lst[j]:
                if y == 1: #行き先が正直者
                    if check[x] != 0:
                        check[x] = 1
                    else: #矛盾しているとき
                        flag = False
                        break
                else: #y == 0
                    if check[x] != 1:
                        check[x] = 0
                    else:
                        flag = False
                        break
        else: #正直者でないとき
            if check[j] == 1:
                flag = False
                break
            else:
                check[j] = 0

        if flag == False:
            break
    if flag:
        tmp = 0
        for j in range(N):
            if (i >> j) & 1:
                tmp += 1
        # print (i)
        # print (check, flag)
        ans = max(ans, tmp)

print (ans)
# print (lst)

# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(eval(input()))
lst = [[] for _ in range(N)]

for i in range(N):
    A = int(eval(input()))
    for _ in range(A):
        XY = tuple(map(int, input().split()))
        lst[i].append(XY)


ans = 0
for i in range(2 ** N):
    count = 0
    flag = True
    for j in range(N):
        if (i >> j) & 1: #正直者の時、証言を確認する
            for x, y in lst[j]:
                if y == 1:
                    if (i >> (x - 1)) & 1:
                        continue
                    else:
                        pass
                if y == 0:
                    if (i >> (x - 1)) & 1:
                        pass
                    else:
                        continue
                flag = False
                break
            count += 1
        if not flag:
            break
    if flag:
        ans = max(ans, count)

print (ans)
# Original solution
# -*- coding: utf-8 -*-
# C

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)
from itertools import product

N = int(eval(input()))
A = [0] * N
x = []

for i in range(N):
    A[i] = int(eval(input()))
    d = []
    for j in range(A[i]):
        d.append(tuple(map(int, input().split())))
    x.append(d)

# print(x)

ans = 0
for case in list(product([0,1], repeat=N)):
    # print(case)

    flg = [-1] * N
    cond = True
    for i in range(N):
        if not cond:
            continue
        if case[i] == 0:
            continue

        for a in range(A[i]):
            c, d = x[i][a]
            c = c-1

            # print(c, d)
            if case[c] != d:
                cond = False
                # print('矛盾')
    if cond:
        ans = max(ans, sum(case))

print(ans)


# Optimized solution
# -*- coding: utf-8 -*-
# C

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)
from itertools import product

N = int(eval(input()))
A = [0] * N
x = []

for i in range(N):
    A[i] = int(eval(input()))
    d = []
    for j in range(A[i]):
        d.append(tuple(map(int, input().split())))
    x.append(d)

ans = 0

# for case in list(product([0,1], repeat=N)):
for m in range(2**N):
    # print(case)
    flg = [-1] * N
    cond = True
    for i in range(N):
        if not cond:
            continue
        if m >> i & 1 == 0:
            continue

        for a in range(A[i]):
            c, d = x[i][a]
            c = c-1

            # print(c, d)
            if m >> c & 1 != d:
                cond = False
                # print('矛盾')
    if cond:
        # ans = max(ans, sum(case))
        ans = max(ans, bin(m).count('1'))

print(ans)
# Original solution
n = int(eval(input()))
l = []
A = []
for i in range(n):
    a = int(eval(input()))
    A += [a]
    l_1 = []
    for j in range(a):
        l_1 += [list(map(int, input().split()))]
    l += [l_1]

ans = 0

for i in range(1 << n):
    honest = []
    liar = []
    for j in range(n):
        if ((i >> j) & 1):
            if j + 1 in liar:
                break
            elif j + 1 not in honest:
                honest += [j + 1]
            sugg = l[j]

            for k in sugg:
                if k[1] == 1:
                    if k[0] in liar:
                        break
                    elif k[0] not in honest:
                        honest += [k[0]]
                else:
                    if k[0] in honest:
                        break
                    elif k[0] not in liar:
                        liar += [k[0]]
            else:
                continue
            break

        else:
            if j + 1 in honest:
                break
            elif j + 1 not in liar:
                liar += [j + 1]
    else:
        if ans < len(honest):
            ans = len(honest)

print(ans)


# Optimized solution
n = int(eval(input()))
num_of_sug = []
sug = []
for i in range(n):
    m = int(eval(input()))
    num_of_sug += [m]
    sug += [[tuple(map(int, input().split())) for _ in range(m)]]

ans = 0

for i in range(2 ** n):
    liar = []
    honest = []
    for j in range(n):
        if ((i >> j) & 1):
            if j + 1 in liar:
                break
            elif j + 1 not in honest:
                honest += [j + 1]
            sug_tmp = sug[j]

            for sug_ in sug_tmp:
                if sug_[1] == 1:
                    if sug_[0] in liar:
                        break
                    elif sug_[0] not in honest:
                        honest += [sug_[0]]
                else:
                    if sug_[0] in honest:
                        break
                    elif sug_[0] not in liar:
                        liar += [sug_[0]]
            else:
                continue
            break
        else:
            if j + 1 in honest:
                break
            elif j + 1 not in liar:
                liar += [j + 1]
    else:
        if ans < len(honest):
            ans = len(honest)
print(ans)
# Original solution
n = int(eval(input()))
a = [0] * n
s = [[]] * n

for i in range(n):
  a[i] = int(eval(input()))
  tmp = [[]] * a[i]
  for j in range(a[i]):
    tmp[j] = [num for num in map(int, input().split())]
  s[i] = tmp
# print(n)
# print(a)
# print(s)
ans = 0
for i in range(2 ** n):
  pattern = '{:0' + str(n) + 'b}'
  bin_str = pattern.format(i)
  # print(bin_str)
  all_ok = True # すべての人の証言に矛盾がない
  total_honesty = 0
  for j in range(n):
    shogen = s[j]
    if bin_str[j] == '1':
      total_honesty += 1
      # 正直者とした場合
      for k in range(len(shogen)):
        x, y = shogen[k]
        x -= 1
        if int(bin_str[x]) != y:
          all_ok = False
          break
  if all_ok:
    if ans < total_honesty:
      ans = total_honesty
print(ans)


# Optimized solution
n = int(eval(input()))

a = [0] * n
sl = []

for i in range(n):
  a = int(eval(input()))
  s = []
  for j in range(a):
    x, y = list(map(int, input().split()))
    s.append([x, y])
  sl.append(s)
ans = 0

# bit 全探索
# 1 = 正直者、0 = 不親切な人
for i in range(1 << n):
  #print('pattern', bin(i))
  all_ok = True
  for j in range(n):
    # 人j が正直者かどうか
    #print('j : {}'.format(j))
    if i & (1 << j):
      # print(j)
      # 正直者であれば証言に矛盾があってはいけない
      s = sl[j]
      for k in range(len(s)):
        target =  s[k][0]
        kind = s[k][1]
        # print('target {} : kind {}'.format(target, kind))
        #print(target, kind, i & (1 << (target-1)), bool(i & (1 << (target-1))), bool(kind))
        rk = 1 if (i & (1 << (target-1))) > 0 else 0
        if rk != kind :
          #print('証言NG')
          # 証言がNG
          all_ok = False
          break
    if not all_ok:
      break
  else:
    # すべての正直者に矛盾がないパターン
    #print('ok', bin(i))
    ans = max(ans, bin(i).count('1'))
    
#print(sl)
print(ans)
# Original solution
import itertools
n = int(eval(input()))
data = {}
for x in range(n):
    data[x] = []
    for y in range(int(eval(input()))):
        k, l = list(map(int, input().split()))
        data[x].append((k - 1, l))

ans = 0
for i in itertools.product([1,0], repeat=n):
    h = True
    for x in range(n):
        if i[x] == 1:
            for g in data[x]:
                if i[g[0]] != g[1]:
                    h = False
        if h == False:
            break
    if h == True:
        ans = max(ans, sum(list(i)))
print(ans)

# Optimized solution
import itertools
n = int(eval(input()))
data = []
for x in range(n):
    for y in range(int(eval(input()))):
        k, l = list(map(int, input().split()))
        data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
    s = sum(list(i))
    for g in data:
        if i[g[0]] == 1 and i[g[1]] != g[2]:
            s = 0
            break
    ans = max(ans, s)
print(ans)
# Original solution
import itertools
n = int(eval(input()))
data = []
for x in range(n):
    for y in range(int(eval(input()))):
        k, l = list(map(int, input().split()))
        data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
    s = sum(list(i))
    if ans > s:
        continue
    for g in data:
        if i[g[0]] == 1 and i[g[1]] != g[2]:
            s = 0
            break
    ans = max(ans, s)
print(ans)

# Optimized solution
import itertools
import sys
input = sys.stdin.readline
n = int(eval(input()))
data = []
for x in range(n):
    for y in range(int(eval(input()))):
        k, l = list(map(int, input().split()))
        data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
    s = sum(list(i))
    for g in data:
        if i[g[0]] == 1 and i[g[1]] != g[2]:
            s = 0
            break
    ans = max(ans, s)
print(ans)
# Original solution
def dudge(k):
    for i in reversed(list(range(n))):
        p = (k >> i) % 2
        #print(' i = ', i, ' p = ', p)
        if p == 0: continue

        for claim in xy[i]:
            x = claim[0]
            y = claim[1]

            truth = (k >> x-1) % 2
            #print('   x = ', x,  ' y = ', y, ' t = ', truth)
            if truth == 1 and y == 0:
                return False
            elif truth == 0 and y == 1:
                return False
    return True


n = int(eval(input()))

xy = []
for i1 in range(n):
    ai = int(eval(input()))
    xy.append([])

    for i2 in range(ai):
        xi,yi = list(map(int, input().split()))
        xy[i1].append((xi, yi))

#print(xy)

result = 0
for k in reversed(list(range(1 << n))):
    #print(bin(k))

    if dudge(k):
        #print('    True')
        #l = [i for i in range(n) if (k >> i) % 2 == 1]
        cnt = 0
        for i in range(n):
            if (k >> i) % 2 == 1: cnt += 1
        #print('    ', l, len(l))
        #result = max(result, len(l))
        result = max(result, cnt)

print(result)


# Optimized solution
def dudge(k):
    for i in reversed(list(range(n))):
        p = (k >> i) % 2
        #print(' i = ', i, ' p = ', p)
        if p == 0: continue

        for claim in xy[i]:
            x = claim[0]
            y = claim[1]

            truth = (k >> x-1) % 2
            #print('   x = ', x,  ' y = ', y, ' t = ', truth)
            if truth == 1 and y == 0:
                return False
            elif truth == 0 and y == 1:
                return False
    return True


n = int(eval(input()))

xy = []
for i1 in range(n):
    ai = int(eval(input()))
    xy.append([])

    for i2 in range(ai):
        xi,yi = list(map(int, input().split()))
        xy[i1].append((xi, yi))

#print(xy)

result = 0
for k in reversed(list(range(1 << n))):
    #print(bin(k))

    if dudge(k):
        #print('    True')
        l = [i for i in range(n) if (k >> i) % 2 == 1]
        cnt = 0
        #for i in range(n):
        #    if (k >> i) % 2 == 1: cnt += 1
        #print('    ', l, len(l))
        result = max(result, len(l))
        #result = max(result, cnt)

print(result)