qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N=int(input())
g=[[-1]*N for _ in range(N)]
ans=0
for i in range(N):
    A=int(input())
    for _ in range(A):
        x,y=map(int,input().split())
        g[i][x-1]=y
for s in range(2**N):
    flag=1
    for i in range(N):
        if (s>>i)==1:
            for j in range(N):
                if g[i][j]!=-1 and (s>>j&1)!=g[i][j]:
                    flag=0
    if flag==1:
        t=0
        x=s
        while x>0:
            t+=x%2
            x//=2
        ans=max(ans,t)
print(ans)

Fixed code:
N=int(input())
g=[[-1]*N for _ in range(N)]
ans=0
for i in range(N):
    A=int(input())
    for _ in range(A):
        x,y=map(int,input().split())
        g[i][x-1]=y
for s in range(2**N):
    flag=1
    for i in range(N):
        if (s>>i&1):
            for j in range(N):
                if g[i][j]!=-1 and (s>>j&1)!=g[i][j]:
                    flag=0
    if flag==1:
        t=0
        x=s
        while x>0:
            t+=x%2
            x//=2
        ans=max(ans,t)
print(ans)
Buggy code:
n = int(input())

def popcount(x):
    return bin(x).count('1')

g = [[-1 for j in range(n)] for i in range(n)]

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

ans = 0
for i in range(1 << n):
    d = [0 for _ in range(n)]
    for j in range(n):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(n):
        if d[j]:
            for k in range(n):
                if g[j][k] == -1:
                    continue
                if g[j][k] != d[k]:
                    ok = False
    if ok:
        ans = max(ans, popcount(i))

print(ans)

Fixed code:
n = int(input())

def popcount(x):
    return bin(x).count('1')

g = [[-1 for j in range(n)] for i in range(n)]

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

ans = 0
for i in range(1 << n):
    d = [0 for _ in range(n)]
    for j in range(n):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(n):
        if d[j]:
            for k in range(n):
                if g[j][k] == -1:
                    continue
                if g[j][k] != d[k]:
                    ok = False
    if ok:
        ans = max(ans, popcount(i))

print(ans)
Buggy code:
n=int(input())
l=[0 for i in range(n)]
for i in range(n):
  ka=int(input())
  r,w=[],[]
  for k in range(ka):
    x,y=map(int,input().split())
    r.append(x-1) if y else w.append(x-1)
  l[i]=(set(r),set(w))
ans=0
for j in range(2**n):
  v=format(j,"b").zfill(n)
  R,W=set(),set()
  RR={i for i in range(n) if v[i]=="1"}
  for h in RR:
    r,w=l[h]
    R|=r
    W|=w
  WW=set(range(n))-RR
  if len(RR&W) or len(WW&R) or len(R&W) :break
  else:ans=max(ans,len(RR))
print(ans)

Fixed code:
n=int(input())
l=[0 for i in range(n)]
for i in range(n):
  ka=int(input())
  r,w=[],[]
  for k in range(ka):
    x,y=map(int,input().split())
    r.append(x-1) if y else w.append(x-1)
  l[i]=(set(r),set(w))
ans=0
for j in range(2**n):
  v=format(j,"b").zfill(n)
  R,W=set(),set()
  RR={t for t in range(n) if v[t]=="1"}
  for h in RR:
    r,w=l[h]
    R|=r
    W|=w
  WW=set(range(n))-RR
  if len(RR&W) or len(WW&R) or len(R&W) :continue
  else:ans=max(ans,len(RR))
print(ans)
Buggy code:
n=int(input())
a=[]
for i in range(n):
    m=int(input())
    a.append(list(list(map(int,input().split())) for j in range(m)))
print(a)
ans=0
for i in range(2**n):
    r=1
    ib=list(format(i,"b").zfill(n))
    for j in range(n):
        if ib[j]=="1":
            for k in range(len(a[j])):
                if int(ib[a[j][k][0]-1])!=a[j][k][1]:
                    r=0
    if r==1:
        ans=max(ans,ib.count("1"))
print(ans)


Fixed code:
n = int(input())

A =[]
for i in range(n):
    m = int(input())
    A.append([list(map(int,input().split())) for i in range(m)])

# print(A)
ans = 0
for i in range(2**n):
    r = 1
    ib = list(format(i, "b").zfill(n))
    # print(ib)
    for j in range(n):
        if ib[j] == "1":
            for k in range(len(A[j])):
                if int(ib[A[j][k][0]-1]) != A[j][k][1]:
                    r = 0
    if r == 1:
        ans = max(ans, ib.count("1"))
print(ans)
Buggy code:
n = int(input())
g = [[-1] * n] * n

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

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 and (s>>j&1) != g[i][j]:
                    ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)


Fixed code:
n = int(input())

g = [[-1 for j in range(n)] for i in range(n)]

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

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] == -1: continue
				if (s>>j&1) != g[i][j]: ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)
Buggy code:
n=int(input())
A=[]
B=[]
for i in range(n):
   a=int(input())
   A.append(a)
   d=[]
   for j in range(a):
      x,y=map(int,input().split())
      d.append((x,y))
   B.append(d)
c=0
for i in range(2**n):
   L=[0]*n
   for j in range(n):
      if i>>j&1
         L[j]=1
   if 1 in L:
      flag=True
      for k in range(n):
         if L[k]==1:
            for m in range(A[k]):
               if L[B[k][m][0]-1]!=B[k][m][1]:
                  flag=False
                  break
      if flag:
         c=max(sum(L),c)
print(c)

Fixed code:
n=int(input())
A=[]
B=[]
for i in range(n):
   a=int(input())
   A.append(a)
   d=[]
   for j in range(a):
      x,y=map(int,input().split())
      d.append((x,y))
   B.append(d)
ans=0
for i in range(2**n):
   L=[0]*n
   for j in range(n):
      if i>>j&1:
         L[j]=1
   if 1 in L:
      flag=True
      for k in range(n):
         if L[k]==1:
            for m in range(A[k]):
               if L[B[k][m][0]-1]!=B[k][m][1]:
                  flag=False
                  break
      if flag:
         ans=max(sum(L),ans)
print(ans)
Buggy code:
n=int(input())
a=[]
b=[]

for i in range(n):
      aa=int(input())
      a.append(aa)
      d=[]
      for j in range(aa):
            x,y=map(int,input().split())
            d.append((x,y))
      b.append(d)

for i in range(2**n):
      L=[0]*n
      for j in range(n):
            if ((i>>j)&1):
                  L[j]=1
      cc=0
      if 1 in L:
            flag=1
            for k in range(n):
                  if L[k]==1:
                        for m in range(a[k]):
                              if L[b[k][m][0]-1]!=b[k][m][1]:
                                    flag=0
                                    break
            if flag==1:
                  cc=max(sum(L),cc)
print(cc)
                        


Fixed code:
n=int(input())
a=[]
b=[]

for i in range(n):
      aa=int(input())
      a.append(aa)
      d=[]
      for j in range(aa):
            x,y=map(int,input().split())
            d.append((x,y))
      b.append(d)
cc=0
for i in range(2**n):
      L=[0]*n
      for j in range(n):
            if ((i>>j)&1):
                  L[j]=1
      if 1 in L:
            flag=True
            for k in range(n):
                  if L[k]==1:
                        for m in range(a[k]):
                              if L[b[k][m][0]-1]!=b[k][m][1]:
                                    flag=False
                                    break
            if flag:
                  cc=max(sum(L),cc)
print(cc)
Buggy code:
from itertools import product

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

ans = 0

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

print(ans)


Fixed code:
from itertools import product

n = int(input())
xy = []

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

ans = 0

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

print(ans)
Buggy code:
n=int(input())

talk=[]

for _ in range(n):
    a=int(input())
    sei=set([])
    uso=set([])
    for __ in range(a):
        x,y=map(int,input().split())
        if y==1:
            sei.add(x-1)
        else:
            uso.add(x-1)
    
    talk.append((sei,uso))
#print(talk)
result=0
for i in range(2**n):
    #print(bin(i))
    flag=0
    s=str(bin(i))[2:].zfill(n)
    #print("#####",s)
    kari_sei=set([])
    kari_uso=set([])

    for j in range(n):
        if i>>j &1:
            kari_sei.add(j)
        else:
            kari_uso.add(j)

    flag=0
    for item in kari_sei:
        for item2 in talk[item-1][0]:
            if item2 not in kari_sei:
                flag=1
                break
        if flag==1:
            break
        else:
            for item2 in talk[item-1][1]:
                if item2 not in kari_uso:
                    flag=1
                    break
            
    
    if flag==0:
        result=max(result,s.count("1"))

print(result)






Fixed code:
n=int(input())

talk=[]

for _ in range(n):
    a=int(input())
    sei=set([])
    uso=set([])
    for __ in range(a):
        x,y=map(int,input().split())
        if y==1:
            sei.add(x-1)
        else:
            uso.add(x-1)
    
    talk.append((sei,uso))
#print(talk)
result=0
for i in range(2**n):
    flag=0
    s=str(bin(i))[2:].zfill(n)
    #print("#####",s)
    kari_sei=set([])
    kari_uso=set([])

    for j in range(n):
        if i>>j &1:
            kari_sei.add(j)
        else:
            kari_uso.add(j)

    flag=0
    for item in kari_sei:
        for item2 in talk[item][0]:
            if item2 not in kari_sei:
                flag=1
                break
        if flag==1:
            break
        else:
            for item2 in talk[item][1]:
                if item2 not in kari_uso:
                    flag=1
                    break
            
    
    if flag==0:
        result=max(result,s.count("1"))

print(result)
Buggy code:
def bitcnt(n):
  n=(n&0x55555555)+(n>>1&0x55555555)
  n=(n&0x33333333)+(n>>2&0x33333333)
  n=(n&0x0f0f0f0f)+(n>>4&0x0f0f0f0f)
  n=(n&0x00ff00ff)+(n>>8&0x00ff00ff)
  n=(n&0x0000ffff)+(n>>16&0x0000ffff)
  return n
N = int(input())
xy = [[-1 for j in range(N)] for i in range(N)]
for i in range(N):
  for j in range(int(input())):
    x, y = map(int, input().split())
    x -= 1
    xy[i][x] = y
r = 0
for i in range(1<<N):
  t = [i>>j&1 for j in range(N)]
  ok = True
  for j in range(N):
    if t[j]:
      for k in range(N):
        if xy[j][k] == -1:
          continue
        if xy[j][k] != t[j]:
          ok = False
          break
  if ok:
    r = max(r, bitcnt(i))
print(r)

Fixed code:
def bitcnt(n):
  n=(n&0x55555555)+(n>>1&0x55555555)
  n=(n&0x33333333)+(n>>2&0x33333333)
  n=(n&0x0f0f0f0f)+(n>>4&0x0f0f0f0f)
  n=(n&0x00ff00ff)+(n>>8&0x00ff00ff)
  n=(n&0x0000ffff)+(n>>16&0x0000ffff)
  return n
N = int(input())
xy = [[-1 for j in range(N)] for i in range(N)]
for i in range(N):
  for j in range(int(input())):
    x, y = map(int, input().split())
    x -= 1
    xy[i][x] = y
r = 0
for i in range(1<<N):
  t = [i>>j&1 for j in range(N)]
  ok = True
  for j in range(N):
    if t[j]:
      for k in range(N):
        if xy[j][k] == -1:
          continue
        if xy[j][k] != t[k]:
          ok = False
          break
  if ok:
    r = max(r, bitcnt(i))
print(r)
Buggy code:
n = int(input())
comments = {}
for i in range(n):
  a = int(input())
  comments[i] = []
  for _ in range(a):
    x, y = [int(x) for x in input().split()]
    comments[i].append([x-1, y==1])

ans = 0
for i in range(2**n):
  results = [None] * n
  for j in range(n):
    candidate = (i >> j) & 1
    if results[j] is None:
      results[j] = candidate
    if results[j] != candidate:
      break
    if candidate == False:
      continue
    if candidate == True:
      failed = False
      for comment in comments[j]:
        if results[comment[0]] is None:
          results[comment[0]] = comment[1]
        if results[comment[0]] != comment[1]:
          failed = True
          break
      if failed:
        break
  else:
    cnt = len([r for r in results if r is True])
    if cnt > ans:
      ans = cnt

print(ans)


Fixed code:
n = int(input())
comments = {}
for i in range(n):
  a = int(input())
  comments[i] = []
  for _ in range(a):
    x, y = [int(x) for x in input().split()]
    comments[i].append([x-1, y==1])

ans = 0
for i in range(2**n):
  results = [None] * n
  for j in range(n):
    candidate = ((i >> j) & 1) == 1
    if results[j] is None:
      results[j] = candidate
    elif results[j] != candidate:
      break
    if candidate == False:
      continue
    elif candidate == True:
      failed = False
      for comment in comments[j]:
        if results[comment[0]] is None:
          results[comment[0]] = comment[1]
        if results[comment[0]] != comment[1]:
          failed = True
          break
      if failed:
        break
  else:
    cnt = len([r for r in results if r is True])
    if cnt > ans:
      ans = cnt

print(ans)
Buggy code:
import itertools

N = int(input())

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

saidai = 0
for i in itertools.product(range(2), repeat=N):
    ans = [-1]*N
    Flag = True
    for j in range(N):
        if i[j] == 1:
            if ans[j] == 0:
                Flag = False
                break
            ans[j] = 1

            for k in A[j]:
                if ans[k[0]] == k[1] or ans[k[0]] == -1:
                    ans[k[0]] = k[1]
                else:
                    Flag = False
                    break
    if Flag == True:
        saidai = max(ans.count(1), saidai)

print(saidai)

Fixed code:
import itertools

N = int(input())

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

saidai = 0
for i in itertools.product(range(2), repeat=N):
    ans = list(i)
    Flag = True
    for j in range(N):
        if ans[j] == 1:
            for k in A[j]:
                if ans[k[0]] == k[1] or ans[k[0]] == -1:
                    ans[k[0]] = k[1]
                else:
                    Flag = False
                    break
    if Flag == True:
        saidai = max(ans.count(1), saidai)

print(saidai)
Buggy code:
N = int(input())

X = [[[-1]*N] for i in range(N)]
for i in range(N):
    a = int(input())
    for i in range(a):
        b, c = map(int, input().split())
        X[i][b-1] = c
ans = 0
for i in range(2**N):
    Y = [0]*(N)
    for j in range(N):
        if ((i >> j) & 1):
            Y[j] = 1
    for j in range(N):
        if Y[j] == 1:
            for k in range(N):
                if X[j][k] == -1:
                    continue
                if X[j][k] != Y[j]:
                    Y[j] = 0
    ans = max(ans, sum(Y))

print(ans)

Fixed code:
N = int(input())

X = [[-1]*N for i in range(N)]
for i in range(N):
    a = int(input())
    for j in range(a):
        b, c = map(int, input().split())
        X[i][b-1] = c
ans = 0
for i in range(2**N):
    Y = [0]*(N)
    for j in range(N):
        if ((i >> j) & 1):
            Y[j] = 1
    flag = True
    for j in range(N):
        if Y[j] == 1:
            for k in range(N):
                if X[j][k] == -1:
                    continue
                if X[j][k] != Y[k]:
                    flag = False
    if flag:
        ans = max(ans, sum(Y))

print(ans)
Buggy code:
N = int(input())
A = []
x = []
y = []
xy = [[] for _ in range(N)]
for i in range(N):
    A1 = int(input())
    A.append(A1)
    for _ in range(A1):
        x, y = map(int, input().split())
        xy[i].append((x-1, y))

c_max = 0
cnt = 0
for i in range(1 << N):
    ok = True
    for j in range(N):
        if (i << j) & 1:
            continue
        for x, y in (xy[j]):
            if (i >> x) & 1 != y:
                ok = False
                break
        if not ok:
            break

    if ok:
        cnt = bin(i)[2:].count('1')
        if cnt > c_max:
            c_max = cnt

print(c_max)


Fixed code:
N = int(input())
A = []
x = []
y = []
xy = [[] for _ in range(N)]
for i in range(N):
    A1 = int(input())
    A.append(A1)
    for _ in range(A1):
        x, y = map(int, input().split())
        xy[i].append((x-1, y))

c_max = 0
cnt = 0
for i in range(1 << N):
    ok = True
    for j in range(N):
        if (i >> j) & 1:
            for x, y in (xy[j]):
                if (i >> x) & 1 != y:
                    ok = False
                    break
        if not ok:
            break

    if ok:
        cnt = bin(i)[2:].count('1')
        if cnt > c_max:
            c_max = cnt

print(c_max)
Buggy code:
A = [0]*N
for i in range(N):
    a = int(input())
    A[i]=a
    li[i]=[list(map(int,input().split())) for i in range(a)]

counter = 0
for humen in product([0,1],repeat=N):
    flag = True
    for i in range(N):
        if humen[i]==1:
            for s in range(A[i]):
                if not li[i][s][1]==humen[li[i][s][0]-1]:
                    flag=False
                    break
        
                
    if flag :
        counter = max(counter,humen.count(1))


print(counter)


Fixed code:
from itertools import product

N = int(input())

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

counter = 0
for humen in product([0,1],repeat=N):
    flag = True
    for i in range(N):
        if humen[i]==1:
            for s in range(A[i]):
                if not li[i][s][1]==humen[li[i][s][0]-1]:
                    flag=False
                    break
        
                
    if flag :
        counter = max(counter,humen.count(1))


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

ans=0
for i in range(N**2):
    flag=True
    for j in range(N):
        if (i>>j)&1==0:
            continue
        for x,y in evidences[j]:
            if (i>>x)&1!=y:
                flag=False
                break
        if not flag:
            break

    if flag:
        ans=max(ans,bin(i)[2:].count('1'))

print(ans)


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

ans=0
for i in range(2**N):
    flag=True
    for j in range(N):
        if (i>>j)&1==0:
            continue
        for x,y in evidences[j]:
            if (i>>x)&1!=y:
                flag=False
                break
        if not flag:
            break

    if flag:
        ans=max(ans,bin(i)[2:].count('1'))

print(ans)
Buggy code:
import itertools
n = int(input())
data = []
for x in range(n):
    for y in range(int(input())):
        k, l = 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]:
            print("{}".format(g))
            s = 0
            break
    ans = max(ans, s)
print(ans)

Fixed code:
import itertools
n = int(input())
data = []
for x in range(n):
    for y in range(int(input())):
        k, l = 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)
Buggy code:
N = int(input())

s = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = 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 >> j) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)


Fixed code:
N = int(input())

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

result = 0
for i in range(1, 2 ** N):
  t = [-1] * N
  for j in range(N):
    t[j] = (i >> j) & 1
  m = False
  for j in range(N):
    if (i >> j) & 1 == 0:
      continue
    for x, y in s[j]:
      if t[x] != y:
        m = True
        break
  if not m:
    result = max(result, bin(i)[2:].count('1'))
print(result)
Buggy code:
def main():
    from collections import defaultdict
    d = defaultdict(list)
    n = int(input())
    for i in range(n):
        a = int(input())
        for _ in range(a):
            x, y = [int(x) for x in input().split()]
            d[i].append((x, y))

    ans = 0
    from itertools import product
    for ts in product([0, 1], repeat=n):
        if all([ts[i] == y for i in range(n) for x, y in d[i] if ts[i]==1]):
            ans = max(ans, sum(ts))
    print(ans)


if __name__ == '__main__':
    main()

Fixed code:
def main():
    from collections import defaultdict
    d = defaultdict(list)
    n = int(input())
    for i in range(n):
        a = int(input())
        for _ in range(a):
            x, y = [int(x) for x in input().split()]
            d[i].append((x-1, y))

    ans = 0
    from itertools import product
    for ts in product([0, 1], repeat=n):
        if all([ts[x] == y for i in range(n) for x, y in d[i] if ts[i]==1]):
            ans = max(ans, sum(ts))
    print(ans)


if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        g[i][x - 1] = y
        
ans = 0
for s in range(2**n):
    ok = True
    for i in range(n):
        k = 0
        if (s >> i & 1) == 1:
            k += 1
            for j in range(n):
                if g[i][j] == -1:
                    continue
                if (s >> j & 1) != g[i][j]:
                    ok = False
    if ok:
        ans = max(ans, k)

print(ans)

Fixed code:
n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        g[i][x - 1] = y
        
ans = 0
for s in range(2**n):
    ok = True
    k = 0
    for i in range(n):
        if (s >> i & 1) == 1:
            k += 1
            for j in range(n):
                if g[i][j] == -1:
                    continue
                if (s >> j & 1) != g[i][j]:
                    ok = False
    if ok:
        ans = max(ans, k)

print(ans)
Buggy code:
n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    for _ in range(int(input())):
        x,y = map(int,input().split())
        q[i][x-1] = y

ans = 0
for s in range(2**n):
    ok = True
    for i in range(n):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False
    if ok:
        t = str(bin(x)).count("1")
        ans = max(ans,t)
print(ans)

Fixed code:
n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    for _ in range(int(input())):
        x,y = map(int,input().split())
        g[i][x-1] = y

ans = 0
for s in range(2**n):
    ok = True
    for i in range(n):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False
    if ok:
        t = str(bin(s)).count("1")
        ans = max(ans,t)
print(ans)