CodeEff/ECCO huggingface dataset:
# Original solution
import sys
input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(eval(input()))
        for j in range(m):
            x, y = list(map(int, input().split()))
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h, u = set(), set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
                h |= A[j][1]
                u |= A[j][0]
            else:
                u.add(j+1)
        if not (h & u):
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
import sys
input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(eval(input()))
        for j in range(m):
            x, y = list(map(int, input().split()))
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h, u = set(), set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
                h |= A[j][1]
                u |= A[j][0]
            else:
                u.add(j+1)
        if not (h & u):
            ans = max(ans, len(h))
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
# ABC147C - HonestOrUnkind2
from itertools import combinations


def main():
    N = int(eval(input()))
    testimonies = {i: {} for i in range(1, N + 1)}
    for i in range(1, N + 1):
        A = int(eval(input()))
        for _ in range(A):
            x, y = list(map(int, input().split()))
            testimonies[i][x] = y

    for cnt_honest in range(N, 0, -1):
        for honest_people in combinations(list(range(1, N + 1)), cnt_honest):
            honest_people = set(honest_people)
            is_consistent = True
            for i in honest_people:
                for x, y in list(testimonies[i].items()):
                    if (x in honest_people and not y) or (x not in honest_people and y):
                        is_consistent = False
                        break
                if not is_consistent:
                    break
            if is_consistent:
                print(cnt_honest)
                return
    print((0))


if __name__ == "__main__":
    main()


# Optimized solution
# ABC147C - HonestOrUnkind2
from itertools import combinations


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

    for cnt_honest in range(N, 0, -1):
        for honest_people in combinations(list(range(1, N + 1)), cnt_honest):
            honest_people = set(honest_people)
            is_consistent = True
            for i in honest_people:
                for x, y in testimonies[i]:
                    if (x in honest_people and not y) or (x not in honest_people and y):
                        is_consistent = False
                        break
                if not is_consistent:
                    break
            if is_consistent:
                print(cnt_honest)
                return
    print((0))


if __name__ == "__main__":
    main()
# Original solution
from itertools import product

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

ans = 0
for pattern in product(list(range(2)), repeat=N): # 0:不正直 1:正直
  flag = True
  for i in range(N):
    if pattern[i]: # iさんが正直と仮定
      # 発言と一致するか？
      for a in range(A[i]):
        if pattern[XY[i][a][0]-1] != XY[i][a][1]:
          flag = False
          break
  if flag:
    ans = max(ans, sum(pattern))

print(ans)

# Optimized solution
N = int(eval(input()))
XY = []
for i in range(N):
  A = int(eval(input()))
  XY.append([list(map(int, input().split())) for _ in range(A)])

ans = 0
for bit in range(1 << N):
  honest_cnt = 0
  flag = True
  for i in range(N):
    if (bit >> i) & 1 == 0:
      continue
    honest_cnt += 1
    for x, y in XY[i]:
      if (bit >> (x-1)) & 1 != y:
        flag = False
        break
  if flag:
    ans = max(ans, honest_cnt)
    
print(ans)
# Original solution
N=int(eval(input()))
A=[]
X=list()
for i in range(N):
   X.append([])

Y=list()
for i in range(N):
   Y.append([])

for i in range(N):
   A_i=int(eval(input()))
   A.append(A_i)

   for j in range(A_i):
      x,y=list(map(int,input().split()))
      X[i].append(x)
      Y[i].append(y)

max_nin=0
#bit全探索
for i in range(1<<N):
   honest_kamo=[]
   for j in range(N):
      if(i>>j)&1:
         honest_kamo.append(j)

   liar_kamo=[c for c in range(N)]
   liar_kamo=list(set(liar_kamo)-set(honest_kamo))
   #print("honest_kamo:",honest_kamo)
   #print("liar_kamo:",liar_kamo)

   flag=True
   for i in honest_kamo:
      for j in range(A[i]):
         if Y[i][j]==1:
            if X[i][j]-1 in liar_kamo:
               flag=False
         elif Y[i][j]==0:
            if X[i][j]-1 in honest_kamo:
               flag=False
   
   #print(flag)
   if flag:
      max_nin=max(max_nin,len(honest_kamo))

print(max_nin)

# Optimized solution
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    shogen=[]
    nums=[]
    for i in range(n):
        a=int(readline())
        nums.append(a)
        xy=[0]*a
        for j in range(a):
            xy[j]=list(map(int,readline().split()))
        shogen.append(xy)
    
    res=0
    for i in range(1<<n):
        output=[]
        for j in range(n):
            if(i>>j)&1:
                output.append(j)
        
        flag=True
        for p in output:
            num_p=nums[p]
            shogen_p=shogen[p]
            for j in range(num_p):
                if shogen_p[j][1]==1:
                    if shogen_p[j][0]-1 in output:
                        pass
                    else:
                        flag=False
                        break
                else:
                    if shogen_p[j][0]-1 in output:
                        flag=False
                        break
                    else:
                        pass
            if flag==False:
                break
        else:
            res=max(res,len(output))

    print(res)

if __name__=="__main__":
    main()
# Original solution
N = int(eval(input()))
path = []
ans = 0
ap = path.append
for i in range(N):
    A = int(eval(input()))
    ap([])
    for j in range(A):
        x, y = list(map(int,input().split()))
        x -= 1
        path[-1].append((x, y))
for i in range(1<<N):
    i |= (1<<N)
    judge = True
    for j in range(N):
        if (1<<j) & i:
            for k in range(len(path[j])):
                if path[j][k][1] != int(bin(i)[-path[j][k][0] - 1]):
                    judge = False
    if judge:
        if ans < bin(i).count("1") - 1:
            ans = bin(i).count("1") - 1
print(ans)

# Optimized solution
N = int(eval(input()))
path = []
ans = 0
for i in range(N):
    A = int(eval(input()))
    path.append([])
    for j in range(A):
        x, y = list(map(int,input().split()))
        x -= 1
        path[-1].append((x, y))
for i in range(1<<N):
    i |= (1<<N)
    judge = True
    for j in range(N):
        if not judge:
            break
        if (1<<j) & i:
            for k in range(len(path[j])):
                if path[j][k][1] != int(bin(i)[-path[j][k][0] - 1]):
                    judge = False
                    break
    if judge:
        if ans < bin(i).count("1") - 1:
            ans = bin(i).count("1") - 1
print(ans)
# Original solution
n = int(eval(input()))
la, lxy = [], []
for i in range(n):
  a = int(eval(input()))
  la.append(a)
  xy = []
  for j in range(a):
    xy.append(list(map(int, input().split())))
  lxy.append(xy)

lb = []
for i in range(2**n):
  lb += [str(bin(i))[2:].zfill(n)]
lc = [sum(int(j) for j in i) for i in lb]
lc, lb = list(zip(*sorted(zip(lc, lb), reverse=True)))
lb = [[int(j) for j in i] for i in lb]

for l in lb:
  ok = 1
  for i in range(n):
    a = la[i]
    for j in range(a):
      x, y = lxy[i][j]
      if l[i] == 1 and l[x-1] != y:
        ok = 0
        break
  if ok:
    print((sum(int(k) for k in l)))
    break
else:
  print((0))

# Optimized solution
import sys
input = sys.stdin.readline

n = int(eval(input()))
la, lxy = [], []
for i in range(n):
  a = int(eval(input()))
  la.append(a)
  xy = []
  for j in range(a):
    xy.append(list(map(int, input().split())))
  lxy.append(xy)

lb = []
for i in range(2**n):
  lb += [str(bin(i))[2:].zfill(n)]
lc = [sum(int(j) for j in i) for i in lb]
lc, lb = list(zip(*sorted(zip(lc, lb), reverse=True)))
lb = [[int(j) for j in i] for i in lb]

for l in lb:
  ok = 1
  for i in range(n):
    a = la[i]
    for j in range(a):
      x, y = lxy[i][j]
      if l[i] == 1 and l[x-1] != y:
        ok = 0
        break
  if ok:
    print((sum(int(k) for k in l)))
    break
else:
  print((0))
# Original solution
n=int(eval(input()))
A=[{} for _ in range(n)]
for i in range(n):
  for _ in range(int(eval(input()))):
    x,y=list(map(int,input().split()))
    A[i][x]=y
a=0
for i in range(2**n):
  t=0
  for j in range(n):
    if i>>j&1:
      if A[j] and any(i>>~-k&1!=A[j][k] for k in A[j]): break
      else: t+=1
  else: a=max(a,t)
print(a)

# Optimized solution
n=int(eval(input()))
A=[]
for i in range(n):
  for _ in range(int(eval(input()))):
    x,y=list(map(int,input().split()))
    A+=[(i,x-1,y)]
a=0
for i in range(2**n):
  if all(i>>j&1<1 or i>>x&1==y for j,x,y in A):
    a=max(a,sum(map(int,bin(i)[2:])))
print(a)
# Original solution
N = int(eval(input()))

XY = []
for _ in range(N):
    A = int(eval(input()))

    temp = []
    for _ in range(A):
        temp.append(list(map(int, input().split())))

    XY.append(temp)


max_honest = 0
for c in range(1 << N):
    check = [0] * N
    contradict = False
    temp = c

    cnt2 = 0
    while temp != 0:
        if 1 & temp:
            check[cnt2] = 1

        temp >>= 1
        cnt2 += 1

    for i in range(N):
        if check[i] == 1:
            for x, y in XY[i]:
                if check[x - 1] != y:
                    contradict = True
                    break

            if contradict:
                break

    if not contradict:
        cnt1 = 0
        for i in range(N):
            if check[i] is not None and check[i] == 1:
                cnt1 += 1

        max_honest = max(max_honest, cnt1)


print(max_honest)


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

XY = []
for _ in range(N):
    A = int(eval(input()))

    temp = []
    for _ in range(A):
        temp.append(list(map(int, input().split())))

    XY.append(temp)


max_honest = 0
for c in range(1 << N):
    check = [0] * N
    contradict = False

    cnt1 = 0
    while c != 0:
        if 1 & c:
            check[cnt1] = 1

        c >>= 1
        cnt1 += 1

    for i in range(N):
        if check[i] == 1:
            for x, y in XY[i]:
                if check[x - 1] != y:
                    contradict = True
                    break

            if contradict:
                break

    if not contradict:
        max_honest = max(max_honest, sum(check))


print(max_honest)
# Original solution
N  = int(eval(input()))
testimony = [[]for i in range(N)]
for i in range(N):
    num = int(eval(input()))
    for j in range(num):
        person, state = list(map(int, input().split()))
        testimony[i].append([person-1,state])#3次元配列の作り方
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if(i>>j)&1 == 1:
            for x,y in testimony[j]:#3次元リストからx,yを取り出す書きかた　覚える
                if (i>>x)&1 != y: #正直といっているがそうではない　と　嘘つきといっているがそうではない　の二つ同時
                    flag =1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))# bin()で二進数に変換　最初の二文字は0bで取り除く count('1')で数える
print(honest)


# Optimized solution
n = int(eval(input()))
testimony = [[] for _ in range(n)]
for i in range(n):
    for j in range(int(eval(input()))):
        x,y = list(map(int, input().split()))
        testimony[i].append((x,y))
honest = 0
for i in range(2**n):
    flag = True
    for j in range(n):
        if (i>>j)&1:
            for x,y in testimony[j]:
                if (i>>(x-1))&1 != y:
                    flag = False
                    break
    if flag:
        honest = max(honest, bin(i)[2:].count('1'))
print(honest)
# Original solution
n = int(eval(input()))


def make_remark_list(i, r):
    # -1: 不明, 0: 嘘つき, 1: 真実
    people = [-1] * n
    people[i] = 1
    for x, y in r:
        people[x - 1] = y
    return people


def check(x, y):
    new_list = []
    for a, b in zip(x, y):
        a, b = min(a, b), max(a, b)
        if (a, b) == (0, 1):
            return False
        elif (a, b) == (-1, 0):
            new_list.append(0)
        else:
            new_list.append(max(a, b))
    return new_list


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

def max_count(r, cnt, i = 0):
    tmp = r
    for j, r_j in enumerate(remarks):
        if j < i: continue
        if tmp[j] == 0:
            continue
        elif tmp[j] == 1:
            if check(tmp, r_j):
                tmp = check(tmp, r_j)
                cnt += 1
            else:
                cnt = 0
                break
        else:
            tmp[j] = 1
            if check(tmp, r_j):
                cnt_1, tmp_1 = max_count(tmp, cnt, j)
                tmp[j] = 0
                cnt_0, tmp_0 = max_count(tmp, cnt, j)
                if cnt_0 > cnt_1:
                    return cnt_0, tmp_0
                else:
                    return cnt_1, tmp_1
            else:
                tmp[j] = 0
    return cnt, tmp

r = [-1] * n
cnt, r = max_count(r, 0)
print(cnt)

# Optimized solution
def check(x, y):
    for a, b in zip(x, y):
        if a != b and b != -1:
            return False
    else:
        return True


n = int(eval(input()))
remarks = []
cnt_max = 0
for _ in range(n):
    a = int(eval(input()))
    x = [tuple(map(int, input().split())) for i in range(a)]
    r = [-1] * n
    for i, j in x:
        r[i - 1] = j
    remarks.append(r)
for r in range(2 ** n):
    r = list(bin(r)[2:].zfill(n))
    r = [int(i) for i in r[:]]
    cnt = 0
    for i in range(n):
        if r[i] == 1:
            flag = check(r, remarks[i])
            cnt += 1
            if not flag:
                cnt = 0
                break
    cnt_max = max(cnt, cnt_max)
print(cnt_max)
# Original solution
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = list(map(int,readline().rstrip().split()))
        tes[i][x-1] = y #ここまでが入力

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1 #全状態2**N通りを作っておく
    flag = True
    for j in range(N):
        if hon[j]:      #hon=1ならtesとの整合性を比較
            for k in range(N):
                if tes[j][k] == -1:
                    continue    #証言されていない部分は飛ばす
                if tes[j][k] != hon[k]:
                    flag = False
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

# Optimized solution
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = list(map(int,readline().rstrip().split()))
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if hon[j]:
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
        if not flag:
            break
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)
# Original solution
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = list(map(int,readline().rstrip().split()))
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if hon[j]:
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
            if not flag:
                break
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

# Optimized solution
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = list(map(int,readline().rstrip().split()))
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if not flag:
            break
        if hon[j]:
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
            
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)
# Original solution
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = list(map(int,readline().rstrip().split()))
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if not flag:
            break
        if hon[j]:
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
            
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

# Optimized solution
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[] for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = list(map(int,readline().rstrip().split()))
        tes[i].append((x-1,y))

cnt = 0
for i in range(2**N):
    flag = True
    for j in range(N):
        if (i>>j)&1 == 1:
            for x,y in tes[j]:
                if (i>>x)&1 != y:
                    flag = False
                    break
    if flag:
        cnt = max(cnt,bin(i)[2:].count("1"))
print(cnt)
# Original solution
import sys
input = sys.stdin.readline

N = int(eval(input()))
STATE = [[]]*N
for i in range(N):
    a = int(eval(input()))
    STATE[i] = [list(map(int, input().split())) for i in range(a)]

def main():
    ans = 0
    for i in range(1<<N):
        ans = max(ans, detect(i))
    print(ans)

def detect(i):
    ONT = 0
    for j in range(N):
        if  not (i & 1<<j):
            continue
        ONT += 1
        for x, y in STATE[j]:

            if (y==0) ^ (i>>(x-1) & 1) == 0:
                return 0
    return ONT

if __name__ == '__main__':
    main()

# Optimized solution
import sys
input = sys.stdin.readline
def main():
    N  = int(eval(input()))
    R = [[] for i in range(N)]
    for i in range(N):
        A = int(eval(input()))
        R[i] = [list(map(int, input().split())) for i in range(A)]
    ans = 0
    for i in range(1<<N):
        CNT = 0
        for j in range(N):
            if not (i>>j & 1):
                continue
            CNT += 1
            for x, y in R[j]:
                if y == 1 and (i>>(x-1) & 1):
                    continue
                elif y == 0 and (not (i>>(x-1) & 1)):
                    continue
                else:
                    CNT = 0
                    break
            else:
                continue
            break

        ans = max(ans, CNT)
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
from itertools import product

n = int(eval(input()))

d = {}
for i in range(n):
  a = int(eval(input()))
  for _ in range(a):
    x, y = list(map(int, input().split()))
    if i + 1 not in d:
      d[i + 1] = []
    d[i + 1].append((x, y))

ret = 0
for x in product((0, 1), repeat=n):
  tmp = [-1] * n
  ok = True
  for i in range(n):
    if x[i] == 1 and i + 1 in d:
      for y in d[i + 1]:
        if tmp[y[0] - 1] == -1:
          tmp[y[0] - 1] = y[1]
        elif tmp[y[0] - 1] != y[1]:
          ok = False
          break
    if not ok:
      break
  if ok and all(a == b or b == -1 for a, b in zip(x, tmp)):
    ret = max(ret, sum(x))

print(ret)

# Optimized solution
from itertools import product

n = int(eval(input()))

d = {}
for i in range(n):
  a = int(eval(input()))
  for _ in range(a):
    x, y = list(map(int, input().split()))
    if i + 1 not in d:
      d[i + 1] = []
    d[i + 1].append((x, y))

ret = 0
for x in product((0, 1), repeat=n):
  ok = True
  for i in range(n):
    if x[i] == 0 or i + 1 not in d:
      continue
    for p, tf in d[i + 1]:
      if x[p - 1] != tf:
        ok = False
        break
    if not ok:
      break
  if ok:
    ret = max(ret, sum(x))

print(ret)
# Original solution
n = int(eval(input()))
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(eval(input()))
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            for l in range(a[k]):
                if(honest[k]==1 and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        if f:
            ans = max(ans,honest.count(1))

print(ans)

# Optimized solution
n = int(eval(input()))
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(eval(input()))
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
cnt=0
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
            cnt+=1
        else:
            honest[j] = 0
            
    f = True
    for k in range(n):
        if honest[k]!=1:
            continue
        for l in range(a[k]):
            if y[k][l]!=honest[x[k][l]]:
                f = False
                break
    if f:
        ans = max(ans,cnt)
    cnt=0

print(ans)