CodeEff/ECCO huggingface dataset:
# 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 range(n):
        p = (k >> i) % 2
        if p == 0: continue

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

            truth = (k >> x-1) % 2
            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))

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

print(result)
# Original solution
n = int(eval(input()))
testimony = []  # 各iの証言
for i in range(n):
    t = []
    for _ in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        t.append((x - 1, y))
    testimony.append(t)
best = 0  # 正直者の最大人数
for honest in range(1 << n):  # 正直者をあらかじめ仮定して破綻を確認する
    tmp = 0
    for i in range(n):  # 証言者i
        if not (honest >> i) & 1:  # iが不親切な人なら証言を聞かない
            continue
        tmp += 1
        for j, t in testimony[i]:  # iによるjに対する証言t
            if (honest >> j) & 1 ^ t:  # jに対する仮定とtが食い違えば破綻
                break
        else:
            continue
        break
    else:  # 全ての正直者に話を聞いて破綻が無ければ更新
        best = max(best, tmp)
print(best)


# Optimized solution
n = int(eval(input()))
testimony = []  # 各iの証言
for i in range(n):
    t = []
    for _ in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        t.append((x - 1, y))
    testimony.append(t)
best = 0  # 正直者の最大人数
for honest in range(1 << n):  # 正直者をあらかじめ仮定して破綻を確認する
    for i in range(n):  # 証言者i
        if not (honest >> i) & 1:  # iが不親切な人なら証言を聞かない
            continue
        for j, t in testimony[i]:  # iによるjに対する証言t
            if (honest >> j) & 1 != t:  # jに対する仮定とtが食い違えば破綻
                break
        else:
            continue
        break
    else:  # 全ての正直者に話を聞いて破綻が無ければ更新
        best = max(best, bin(honest).count('1'))
print(best)
# Original solution
def main():
    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 = (int(i) for i in input().split())
            G[i].append((x-1, y))
            # 人iは人xのことをyと言っている

    ans = 0
    for bit in range(1 << N):
        cur = 0
        good = True  # 矛盾がない
        for i in range(N):
            if bit & (1 << i):
                # 人iは正直者
                cur += 1
                for j, y in G[i]:
                    if (bit & (1 << j)) and y == 1:
                        continue
                    elif not(bit & (1 << j)) and y == 0:
                        continue
                    elif (bit & (1 << j)) and y == 0:
                        good = False
                        break
                    elif not(bit & (1 << j)) and y == 1:
                        good = False
                        break
            else:
                # 人iはうそつき
                for j, y in G[i]:
                    if (bit & (1 << j)) and y == 0:
                        continue
                    elif not(bit & (1 << j)) and y == 1:
                        continue
                    elif (bit & (1 << j)) and y == 0:
                        good = False
                        break
                    elif not(bit & (1 << j)) and y == 1:
                        good = False
                        break
        # print(bit, ":", good)
        if good:
            ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    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 = (int(i) for i in input().split())
            G[i].append((x-1, y))
            # 人iは人xのことをyと言っている
    ans = 0
    for bit in range(1 << N):
        cur = 0
        good = True  # 矛盾がない
        for i in range(N):
            if bit & (1 << i):
                # 人iは正直者
                cur += 1
                for j, y in G[i]:
                    if (bit & (1 << j)) and y == 0:
                        good = False
                    elif not(bit & (1 << j)) and y == 1:
                        good = False
        # print(bit, ":", good)
        if good:
            ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
l = [[] 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())))
        l[i].append([x-1,y])

ans = 0
for i in range(1 << n):
    h = []
    for j in range(n):
        h.append(i & 1 << j != 0)
    b = True
    for j in range(n):
        if i & (1 << j) != 0:
            for k in l[j]:
                if (k[1] == 1) != h[k[0]]:
                    b = False
                    break
        if not b:
            break
    
    if b:
        x = 0
        for j in range(n):
            if i & 1 << j:
                x += 1
        ans = max(ans,x)

print(ans)
        


# Optimized solution
n = int(eval(input()))
l = [[] 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())))
        l[i].append([x-1,y])

ans = 0
for i in range(1 << n):
    h = []
    for j in range(n):
        h.append(i & 1 << j != 0)
    b = True
    for j in range(n):
        if i & 1 << j:
            for k in l[j]:
                if (k[1] == 1) != h[k[0]]:
                    b = False
                    break
        if not b:
            break
    if b:
        ans = max(ans,h.count(True))

print(ans)
# Original solution
def digitSum(n):
    s = str(bin(n))
    s = s[2:]
    array = list(map(int, s))
    return sum(array)
N = int(eval(input()))
A = []
X = []
Y = []
res = 0
for i in range(N):
    a = int(eval(input()))
    A.append(a)
    X_temp = []
    Y_temp = []
    for j in range(a):
        x,y = list(map(int,input().split()))
        X_temp.append(x)
        Y_temp.append(y)
    X.append(X_temp)
    Y.append(Y_temp)
for bit in range(1 << N):
    for i in range(1 << N):
        judge = True
        for j in range(N):
            if (i >> j) & 1:#もしAjが正直者だったら
                for k in range(A[j]):
                    if (i >> X[j][k]-1) & 1 != Y[j][k]:
                        judge = False
            else:
                for k in range(A[j]):
                    if (i >> X[j][k]-1) & 1 == Y[j][k]:
                        judge = False
        if judge:
            res = max(res,digitSum(i))
print(res)

# Optimized solution
def digitSum(n):
    s = str(bin(n))
    s = s[2:]
    array = list(map(int, s))
    return sum(array)
N = int(eval(input()))
A = []
X = []
Y = []
res = 0
for i in range(N):
    a = int(eval(input()))
    A.append(a)
    X_temp = []
    Y_temp = []
    for j in range(a):
        x,y = list(map(int,input().split()))
        X_temp.append(x)
        Y_temp.append(y)
    X.append(X_temp)
    Y.append(Y_temp)
for i in range(1 << N):
    judge = True
    for j in range(N):
        if (i >> j) & 1:#もしAjが正直者だったら
            for k in range(A[j]):
                if (i >> X[j][k]-1) & 1 != Y[j][k]:
                    judge = False
        """else:#もしAjが不親切ものだったら。不親切者も正しいことをいうこともある。
            for k in range(A[j]):#
                if (i >> X[j][k]-1) & 1 == Y[j][k]:
                    judge = False"""
    if judge:
        res = max(res,digitSum(i))
print(res)
# Original solution
N = int(eval(input()))

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

result = 0
for i in range(1, 2 ** N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in s[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)


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

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

result = 0
for i in range(1, 2 ** N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in evidences[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)
# Original solution
n = int(eval(input()))

a_list = []
person_list = []
syogen_list = []
ans = 0

for i in range(0, n):
    w = []
    v = []
    a = int(eval(input()))
    for j in range(0, a):
        x,y = list(map(int,input().split()))
        w.append(x)
        v.append(y)
    person_list.append(w)
    syogen_list.append(v)
#print(person_list)
#print(syogen_list)

for bit in range(1 << n):
    break_flag = 0
    bit_1_cnt = 0
    for i in range(n):
        if break_flag:
            break
        if (bit >> i) & 1: #人iが正直
            for j in range(len(syogen_list[i])):
                if syogen_list[i][j] != ((bit>>(person_list[i][j]-1))&1): #矛盾　：　正直としているのに証言が食い違えばbreak
                    break_flag = 1
                    break
            bit_1_cnt += 1
#                if j == len(syogen_list[i])-1:
#                    bit_1_cnt += 1
        if break_flag==0 and i==n-1:
            ans = max(ans, bit_1_cnt)
            #ans = max(ans, bin(bit).count("1"))
print(ans)


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

a_list = []
person_list = []
syogen_list = []
ans = 0

for i in range(0, n):
    w = []
    v = []
    a = int(eval(input()))
    for j in range(0, a):
        x,y = list(map(int,input().split()))
        w.append(x)
        v.append(y)
    person_list.append(w)
    syogen_list.append(v)
#print(person_list)
#print(syogen_list)

for bit in range(1 << n):
    break_flag = 0
    bit_1_cnt = 0
    for i in range(n):
        if break_flag:
            break
        if (bit >> i) & 1: #人iが正直
            for j in range(len(syogen_list[i])):
                if syogen_list[i][j] != ((bit>>(person_list[i][j]-1))&1): #矛盾　：　正直としているのに証言が食い違えばbreak
                    break_flag = 1
                    break
            bit_1_cnt += 1
        if break_flag==0 and i==n-1:
            ans = max(ans, bit_1_cnt)
print(ans)
# Original solution
from itertools import product

n = int(eval(input()))
xy = [[] for i 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 bit in product([0, 1], repeat=n):
    f = 0
    for i, j in enumerate(bit):
        if j == 1:
            for x, y in xy[i]:
                if bit[x - 1] != y:
                    f = 1
                    break
    if f == 0:
        ans = max(ans, sum(bit))
print(ans)


# Optimized solution
from itertools import product


def solve(bit):
    for i, j in enumerate(bit):
        if j == 1:
            for x, y in xy[i]:
                if bit[x - 1] != y:
                    return 0
    return sum(bit)


n = int(eval(input()))
xy = [[] for i 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 bit in product([0, 1], repeat=n):
    ans = max(ans, solve(bit))
print(ans)
# Original solution
n = int(eval(input()))
xys = [[] 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()))
        xys[i].append((x-1, y))

def digitsum(x, base=2):
    ret = 0
    while x>0:
        ret += x % base
        x = x // base
    return(ret)

ans = 0
for i in range(1<<n):
    ok = True
    for j in range(i):
        # if jth person may be honest, verify testimony of him.
        if (i>>j) & 1 == 1:
            for xy in xys[j]:
                x, y = xy
                if (i>>x) & 1 != y:
                    ok = False
                    break
        if not ok:
            break
    if ok:
        ans = max(ans, digitsum(i))
print(ans)

# Optimized solution
n = int(eval(input()))
xys = [[] 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()))
        xys[i].append((x-1, y))

def digitsum(x, base=2):
    ret = 0
    while x>0:
        ret += x % base
        x = x // base
    return ret

ans = 0
for i in range(1<<n):
    ok = True
    for j in range(n):
        # if jth person may be honest, verify testimony of him.
        if (i>>j) & 1 == 1:
            for xy in xys[j]:
                x, y = xy
                if (i>>x) & 1 != y:
                    ok = False
                    break
        if not ok:
            break
    if ok:
        ans = max(ans, digitsum(i))
print(ans)
# Original solution
N = int(eval(input()))
A = [0] * N
X = [[] for _ in range(N)]
for i in range(N):
  A[i] = int(eval(input()))
  for j in range(A[i]):
    X[i].append(list(map(int, input().split())))
Truth = 2 ** N
ans = 0
while(bin(Truth) != bin(2 ** (N + 1))):
  for i in range(N):
    if(bin(Truth)[i+3] == "1"):
      for j in range(A[i]):
        if(int(bin(Truth)[X[i][j][0] + 2]) != X[i][j][1]):
          break
      else:
        continue
      Truth += 1
      break
  else:
    ans = sum(list(map(int,list(bin(Truth)[3:]))))
    Truth += 1
print(ans)

# Optimized solution
N = int(eval(input()))
x = [[0] * (N-1) for _ in range(N)]
y = [[0] * (N-1) for _ in range(N)]
A = [0] * N
for i in range(N):
  A[i] = int(eval(input()))
  for j in range(A[i]):
    x[i][j], y[i][j] = list(map(int, input().split()))
n = 2 ** N
Flag = 0
ans = 0
while(n < 2 ** (N+1)):
  Flag = 0
  for i in range(N):
    if(int(bin(n)[i + 3]) == 1):
      for j in range(A[i]):
        if(y[i][j] != int(bin(n)[x[i][j] + 2])):
          Flag = 1
          break
    if(Flag == 1):
      break
  else:
    ans = max(ans, sum(list(map(int,bin(n)[3:]))))
  n += 1
print(ans)
# Original solution
N = int(eval(input()))

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

ans = 0
for mask in range(1 << N):
    can = True
    for i, s in enumerate(M):
        if (mask & (1 << i)) != 0:
            for x, y in s:
                v = 1 if (mask & (1 << x)) != 0 else 0
                if v != y:
                    can = False
                    break
    if can:
        cnt = 0
        for i in range(N):
            if (mask & (1 << i)) != 0:
                cnt += 1
        ans = max(ans, cnt)

print(ans)

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

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

def sol(state):
    for i, A in enumerate(S):
        if (state & (1 << i)) == 0:
            continue
        for j, s in A:
            if ((state & (1 << (j - 1))) != 0) != (s != 0):
                return 0
    return sum(map(int, bin(state)[2:]))

ans = 0
for state in range(1 << N):
    ans = max(ans, sol(state))
print(ans)
# Original solution
N = int(eval(input()))

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

def sol(state):
    for i, A in enumerate(S):
        if (state & (1 << i)) == 0:
            continue
        for j, s in A:
            if ((state & (1 << (j - 1))) != 0) != (s != 0):
                return 0
    return sum(map(int, bin(state)[2:]))

ans = 0
for state in range(1 << N):
    ans = max(ans, sol(state))
print(ans)


# Optimized solution
N = int(eval(input()))
A = []

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

def exists(state):
    ret = 0
    for i in range(N):
        if ((1 << i) & state) == 0:
            continue
        ret += 1
        for x, y in A[i]:
            if ((state & (1 << (x - 1))) > 0) != (y > 0):
                return 0
    return ret

ans = 0
for state in range(1 << N):
    ans = max(ans, exists(state))
print(ans)
# Original solution
N = int(eval(input()))
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(eval(input()))
    for j in range(A):
        x, y = list(map(int, input().split(' ')))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[0] in honest_ls and t[1] == 0:
                is_ok = False
            if t[0] not in honest_ls and t[1] == 1:
                is_ok = False
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)

# Optimized solution
N = int(eval(input()))
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(eval(input()))
    for j in range(A):
        x, y = list(map(int, input().split(' ')))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[0] not in honest_ls and t[1] == 1:
                is_ok = False
                break
            if t[0] in honest_ls and t[1] == 0:
                is_ok = False
                break
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(eval(input()))
    E=[None]*n
    for i in range(n):
        a=int(eval(input()))
        XY=[tuple(map(int,input().split())) for _ in range(a)]
        E[i]=XY

    N=2**n
    ans=0
    for S in range(N):
        flag=True
        for i in range(n):
            if((S>>i)&1)==0: continue # 正直者のみを見る
            for x,y in E[i]:
                x-=1
                if((S>>x)&1)!=y:
                    flag=False
        if(flag):
            ans=max(ans,bin(S).count('1'))
    print(ans)
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(eval(input()))
    XY=[None]*n
    for i in range(n):
        a=int(eval(input()))
        S=[None]*a
        for j in range(a):
            S[j]=tuple(map(int,input().split()))
        XY[i]=S

    ans=0
    for U in range(1<<n):
        flag=True
        for i in range(n):
            if((U>>i)&1==0): continue
            for x,y in XY[i]:
                x-=1
                if((U>>x)&1)!=y:
                    flag=False
        if(flag):
            ans=max(ans,bin(U).count('1'))

    print(ans)
resolve()
# Original solution
n = int(eval(input()))
ip = []

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

max = 0    
for i in range(n) :
  max += 2**i

ans = 0
for i in range(0,max+1) :
  s = [2 for _ in range(n)]
  bit = i
  count = 0
  index = 0
  check = 0
  for j in range(n) :
    if bit%2 == 1 :
      if s[j] == 0 :
        check = 1
        break
      s[j] = 1
    else :
      if s[j] == 1 :
        check = 1
        break
      s[j] = 0
    bit = bit//2
    for k in range(ip[index]) :
      if s[j] == 1 :
        if ip[index+1+k][1] == 1 :
          if s[ip[index+1+k][0]-1] == 0 :
            check = 1
            break
          s[ip[index+1+k][0]-1] = 1
        elif ip[index+1+k][1] == 0 :
          if s[ip[index+1+k][0]-1] == 1 :
            check = 1
            break
          s[ip[index+1+k][0]-1] = 0
    if check == 1 :
      break
    index += ip[index] + 1
  if ans < s.count(1) and check ==0 :
    ans = s.count(1)

print(ans)

# Optimized solution
n = int(eval(input()))
ip = []

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

max = 0    
for i in range(n) :
  max += 2**i

ans = 0
for i in range(0,max+1) :
  s = [2 for _ in range(n)]
  bit = i
  count = 0
  index = 0
  check = 0
  for j in range(n) :
    if bit%2 == 1 :
      if s[j] == 0 :
        check = 1
      s[j] = 1
    else :
      if s[j] == 1 :
        check = 1
      s[j] = 0
    bit = bit//2
    for k in range(ip[index]) :
      if s[j] == 1 :
        if ip[index+1+k][1] == 1 :
          if s[ip[index+1+k][0]-1] == 0 :
            check = 1
          s[ip[index+1+k][0]-1] = 1
        elif ip[index+1+k][1] == 0 :
          if s[ip[index+1+k][0]-1] == 1 :
            check = 1
          s[ip[index+1+k][0]-1] = 0
    index += ip[index] + 1
  if ans < s.count(1) and check ==0 :
    ans = s.count(1)

print(ans)
# Original solution
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 & (1 << (i - 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)


# Optimized solution
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)