CodeEff/ECCO huggingface dataset:
# Original solution
def main():
    n = int(eval(input()))
    xy = []
    for i in range(n):
        a = int(eval(input()))
        xy.append([tuple(map(int, input().split())) for _ in range(a)])

    c = 0
    for i in range(1 << n):
        all_honest = True
        for j in range(n):
            if (1 << j) & i != 0:
                for x, y in xy[j]:
                    x -= 1  # 人の番号をひとつずらす
                    if ((1 << x) & i) >> x != y:
                        all_honest = False
                        break
            if not all_honest:
                break
        if all_honest:
            popcnt = bin(i).count('1')
            if popcnt > c:
                c = popcnt

    print(c)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    xy = []
    for i in range(n):
        a = int(eval(input()))
        xy.append([tuple(map(int, input().split())) for _ in range(a)])

    c = 0
    for i in range(1 << n):
        popcnt = bin(i).count('1')
        if popcnt <= c:
            continue
        all_honest = True
        for j in range(n):
            if (1 << j) & i != 0:
                for x, y in xy[j]:
                    x -= 1  # 人の番号をひとつずらす
                    if ((1 << x) & i) >> x != y:
                        all_honest = False
                        break
            if not all_honest:
                break
        if all_honest:
            if popcnt > c:
                c = popcnt

    print(c)


if __name__ == '__main__':
    main()
# Original solution
def counter(x):
        if x == 0:
                return 0
        return counter(int(bin(x >> 1), 2)) + int(bin(x & 1), 2)

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

ans = 0 
for bits in range(1, int(bin(1 << N), 2)):
        flag = 1 
        for i in range(N):
                if not int(bin(bits & int(bin(1 << i), 2)), 2): 
                        continue
                for j in range(A[i]):
                        if int(bin(int(bin(bits >> (x[i][j][0] - 1)), 2) & 1), 2) ^ x[i][j][1]:
                                flag = 0 
        if flag:
                ans = max(ans, counter(bits))
print(ans)

# Optimized solution
def counter(x):
        if x == 0:
                return 0
        return counter(x >> 1) + int(bin(x & 1), 2)

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

ans = 0 
for bits in range(1, 1 << N): 
        flag = 1 
        for i in range(N):
                if not int(bin(bits & (1 << i)), 2): 
                        continue
                for j in range(A[i]):
                        if int(bin((bits >> (x[i][j][0] - 1) & 1) ^ x[i][j][1]), 2): 
                                flag = 0 
        if flag:
                ans = max(ans, counter(bits))
print(ans)
# Original solution
def counter(x):
        if x == 0:
                return 0
        return counter(x >> 1) + int(bin(x & 1), 2)

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

ans = 0 
for bits in range(1, 1 << N): 
        flag = 1 
        for i in range(N):
                if not int(bin(bits & (1 << i)), 2): 
                        continue
                for j in range(A[i]):
                        if int(bin((bits >> (x[i][j][0] - 1) & 1) ^ x[i][j][1]), 2): 
                                flag = 0 
        if flag:
                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 = []
x = [0] * N 
for i in range(N):
        A.append(int(eval(input())))
        x[i] = [list(map(int, input().split())) for j in range(A[i])]

ans = 0 
for bits in range(1, 1 << N): 
        flag = 1 
        for i in range(N):
                if not bits & (1 << i): 
                        continue
                for j in range(A[i]):
                        if (bits >> (x[i][j][0] - 1) & 1) ^ x[i][j][1]:
                                flag = 0 
        if flag:
                ans = max(ans, counter(bits))
print(ans)
# Original solution
from itertools import product
N=int(eval(input()))
data=[]
for i in range(N):
    for j in range(int(eval(input()))):
        x,y=list(map(int,input().split()))
        data.append((i,x-1,y))
#print(data)

ans=0
for i in product([1,0],repeat=N):
    #print(i)
    s=True
    for k in data:
        if i[k[0]]==1 and i[k[1]]!=k[2]:
            s=False
            break
    if s:
        ans=max(ans,sum(i))
print(ans)


# Optimized solution
from itertools import product

N=int(eval(input()))
data=[]
for i in range(N):
    for j in range(int(eval(input()))):
        x,y=list(map(int,input().split()))
        data.append((i,x-1,y)) #iさんがx-1さんに嘘(0)or正直(1)


ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in data:
        if i[j[0]]==1 and i[j[1]]!=j[2]:
            ok = False
            break
    if ok:
        ans=max(ans,sum(i))
print(ans)
# Original solution
n = int(eval(input()))
l = [] 
for i in range(n):
	list = [" "] * n
	a = int(eval(input()))
	for j in range(a):
		data = input().split(" ")
		x = int(data[0])
		y = data[1]
		list[x-1] = y
	l.append(list)
m = 0
for i in range(2**n):
	s = bin(i)
	s = s[2:]
	s = s.zfill(n)
	ll = []
	th = [" "] * n
	for j in range(n):
		if int(s[j]) == 1:
			ll.append(l[j])
			th[j] = "1"
		elif int(s[j]) == 0:
			th[j] = "0" 
	te = 0
	for j in range(n):
		cu = "2"
		for k in range(len(ll)):
			if ll[k][j] == "1" and th[j] != "1":
				te = 1
			elif ll[k][j] == "0" and th[j] != "0":
				te = 1
			if ll[k][j] == "1" and cu == "2":
				cu = "1"
			elif ll[k][j] == "0" and cu == "2":
				cu = "0"
			elif ll[k][j] == "0" and cu == "1":
				te = 1
			elif ll[k][j] == "1" and cu == "0":
				te = 1
	if te == 0:
		f = len(ll)
		if f > m:
			m = f
print(m)

# Optimized solution
n = int(eval(input()))
l = [] 
for i in range(n):
	list = [" "] * n
	a = int(eval(input()))
	for j in range(a):
		data = input().split(" ")
		x = int(data[0])
		y = data[1]
		list[x-1] = y
	l.append(list)
m = 0
for i in range(2**n):
	s = bin(i)
	s = s[2:]
	s = s.zfill(n)
	ll = []
	th = [" "] * n
	for j in range(n):
		if int(s[j]) == 1:
			ll.append(l[j])
			th[j] = "1"
		elif int(s[j]) == 0:
			th[j] = "0" 
	te = 0
	for j in range(n):
		for k in range(len(ll)):
			if ll[k][j] == "1" or ll[k][j] == "0":
				if ll[k][j] != th[j]:
					te = 1
	if te == 0:
		f = len(ll)
		if f > m:
			m = f
print(m)
# Original solution
#python3

graph = [[-1 for _ in range(15)] for _ in range(15)]

def main():
    n = int(eval(input()))
    for i in range(n):
        a = int(eval(input()))
        for j in range(a):
            x, y = list(map(int, input().split()))
            graph[i][x-1] = y
            
    ans = 0
    for i in range(1<<15):
        h = [0]*15
        for k in range(n):
            if (i >> k) & 1:
                h[k] = 1

        f = True
        for i in range(15):
            if h[i] == 1:
                for j in range(n):
                    if graph[i][j] == -1:
                        continue
                    if graph[i][j] != h[j]:
                        f = False

        if f:
            ans = max(ans, sum(h))

    print(ans)
main()

# Optimized solution
#python3

def main():
    n = int(eval(input()))
    g = [[-1 for _ in range(n)] 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()))
            g[i][x-1] = y 


    ans = -1
    for i in range(1<<n):
        h = [0 for _ in range(n)]
        for k in range(n):
            if (i>>k) & 1: 
                h[k] = 1

        flag = True
        for j in range(n):
            if h[j] == 1:
                for k in range(n):
                    if g[j][k] == -1:
                        continue
                    if g[j][k] != h[k]:
                        flag = False
        if flag:
            ans = max(sum(h), ans)
    print(ans)
main()
# Original solution
n = int(eval(input()))
a = []
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a.append(int(eval(input())))
    for j in range(a[i]):
        xx, yy = (int(i) for i in input().split())
        x[i].append(xx)
        y[i].append(yy)

hoge = [[2]*n for i in range(n)]

for i in range(n):
    for j in range(a[i]):
        if(y[i][j] == 1):
            hoge[i][x[i][j]-1] = 1
        elif(y[i][j] == 0):
            hoge[i][x[i][j]-1] = 0

ans = 0
b_list = []
for i in range(2**n):
    bit_list = []
    for j in range(n):
        if ((i >> j) & 1):
            bit_list.append(1)
        else:
            bit_list.append(0)
    b_list.append(bit_list)
    flag = 1
    for k in range(n):
        if(bit_list[k] == 1):
            tmp = 0
            for l in range(n):
                if(hoge[k][l] != 2):
                    if(hoge[k][l] != bit_list[l]):
                        flag = 0
                        break
    if(flag == 1):
        tmp = 0
        for l in range(n):
            if(bit_list[l] == 1):
                tmp += 1
        if(tmp > ans):
            ans = tmp
print(ans)


# Optimized solution
n = int(eval(input()))
a = []
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a.append(int(eval(input())))
    for j in range(a[i]):
        xx, yy = (int(i) for i in input().split())
        x[i].append(xx)
        y[i].append(yy)

hoge = [[2]*n for i in range(n)]

for i in range(n):
    for j in range(a[i]):
        if(y[i][j] == 1):
            hoge[i][x[i][j]-1] = 1
        elif(y[i][j] == 0):
            hoge[i][x[i][j]-1] = 0

ans = 0
for i in range(2**n):
    bit_list = []
    for j in range(n):
        if ((i >> j) & 1):
            bit_list.append(1)
        else:
            bit_list.append(0)
    flag = 1
    for k in range(n):
        if(bit_list[k] == 1):
            tmp = 0
            for l in range(n):
                if(hoge[k][l] != 2):
                    if(hoge[k][l] != bit_list[l]):
                        flag = 0
                        break
    if(flag == 1):
        tmp = 0
        for l in range(n):
            if(bit_list[l] == 1):
                tmp += 1
        if(tmp > ans):
            ans = tmp
print(ans)
# Original solution
N=int(eval(input()))

S=[[-1]*N 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][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 S[i][j]!=-1 and (s>>j&1)!=S[i][j]:
          ok=False
  if ok:
    ans=max(ans, bin(s).count("1"))
    
print(ans)


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

A=[[-1]*N 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()))
    A[i][x-1]=y
#正直者が正直者に不親切と言われていない
#→正直ものが不親切を正直者と言っていないか
ans=0
for i in range(2**N):
  ok=True
  for j in range(N):
    if (i>>j&1)==1:
      for k in range(N):
        if A[j][k]!=-1 and (i>>k&1)!=A[j][k]:
          ok=False
  if ok:
    ans=max(ans, bin(i).count("1"))
  
print(ans)
# Original solution
N=int(eval(input()))

A=[[-1]*N 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()))
    A[i][x-1]=y
#正直者が正直者に不親切と言われていない
#→正直ものが不親切を正直者と言っていないか
ans=0
for i in range(2**N):
  ok=True
  for j in range(N):
    if (i>>j&1)==1:
      for k in range(N):
        if A[j][k]!=-1 and (i>>k&1)!=A[j][k]:
          ok=False
  if ok:
    ans=max(ans, bin(i).count("1"))
  
print(ans)

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

#正直者も発言に矛盾が生じない
L=[[-1]*N for _ in range(N)]
for i in range(N):
    A=int(eval(input()))
    for a in range(A):
        x,y=list(map(int, input().split()))
        L[i][x-1]=y
ans=0
for b in range(2**N):
    ok=True
    for i in range(N):
        if b>>i&1==1:
            l=L[i]
            for j,x in enumerate(l):
                if x!=-1 and b>>j&1!=x:
                    ok=False
    if ok:
        ans=max(ans, bin(b).count("1"))

print(ans)
# Original solution
def honestcount(i):
    return bin(i).count("1")

def is_honest(i,j):
    return (i>>j)%2 == 1

N = int(eval(input()))

A = [0] * N
shogens=[]

for i in range(N):
    a = int(eval(input()))
    shogen=[]
    for j in range(a):
        x,y = list(map(int, input().split()))
        shogen.append((x-1,y))
    shogens.append(shogen)
# print(shogens)

count=0
for i in range(1<<N):
    is_ok =True
    for j in range(N):
        if not is_honest(i,j):
            continue
        for x,y in shogens[j]:
            if y!=is_honest(i,x): is_ok=False
    if is_ok:
        count=max(count,honestcount(i))
print(count)


# Optimized solution
def honestcount(i):
    return bin(i).count("1")

def is_honest(i,j):
    return (i>>j)%2 == 1

N = int(eval(input()))

A = [0] * N
shogens=[]

for i in range(N):
    a = int(eval(input()))
    shogen=[]
    for j in range(a):
        x,y = list(map(int, input().split()))
        shogen.append((x-1,y))
    shogens.append(shogen)
# print(shogens)

count=0
for i in range(1<<N):
    is_ok =True
    for j in range(N):
        if not is_honest(i,j):
            continue
        for x,y in shogens[j]:
            if y!=is_honest(i,x):
                is_ok=False
                break
    if is_ok:
        count=max(count,honestcount(i))
print(count)
# Original solution
def main():
    N = int(eval(input()))
    A = [int()] * 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]):
            xij, yij = list(map(int, input().split()))
            x[i].append(xij - 1)
            y[i].append(yij)
    ans = 0
    for b in range(1 << N):
        flg = True
        for i in range(N):
            if not b & 1 << i:
                continue
            for j in range(A[i]):
                if 1 & b >> x[i][j] ^ y[i][j]:
                    flg = False
                    break
            if not flg:
                break
        if flg:
            ans = max(ans, bin(b)[2:].count("1"))
    print(ans)
    return


main()


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int()] * 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]):
            xij, yij = list(map(int, input().split()))
            x[i].append(xij - 1)
            y[i].append(yij)
    ans = 0
    for b in range(1 << N):
        flg = True
        for i in range(N):
            if not b & 1 << i:
                continue
            for j in range(A[i]):
                if 1 & b >> x[i][j] ^ y[i][j]:
                    flg = False
                    break
            if not flg:
                break
        if flg:
            ans = max(ans, bin(b).count("1"))
    print(ans)
    return


main()
# Original solution
def resolve():
    N = int(eval(input()))
    L = [[] for i 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, y))

    ans = 0
    for p in range(1, 2**N):
        isOk = True
        for i in range(N):
            for x, y in L[i]:
                if p & (1 << i):
                    if p & 1 << (x-1) and not y:
                        isOk = False
                        break
                    elif not(p & 1 << (x-1)) and y:
                        isOk = False
                        break

                if not isOk:
                    break

        if isOk:
            ans = max(ans, bin(p).count('1'))

    print(ans)

if __name__ == '__main__':
    resolve()


# Optimized solution
def resolve():
    N = int(eval(input()))
    L = [[] for i 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, y))

    ans = 0
    for p in range(2**N):
        ok = True
        for i in range(N):
            for x, y in L[i]:
                if p & (1 << i):
                    if p & (1 << (x-1)) > 0 and y == 0:
                        ok = False
                        break
                    elif p & (1 << (x-1)) == 0 and y == 1:
                        ok = False
                        break

            if not ok:
                break

        if ok:
            ans = max(ans, bin(p).count('1'))

    print(ans)

if __name__ == '__main__':
    resolve()
# Original solution
n = int(eval(input()))
a = []
for _ in range(n):
    m = int(eval(input()))
    a.append([list(map(int, input().split())) for _ in range(m)])

ans = 0
for i in range(2**n):
    for j in range(n):
        if ((i >> j) & 1) == 1:
            for k,l in a[j]:
                if ((i >> (k-1)) & 1) != l:
                    break
            else:
                continue
            break
    else:
        ans = max(ans,bin(i).count('1'))
print(ans)

# Optimized solution
n = int(eval(input()))
evi = []
for _ in range(n):
    m = int(eval(input()))
    evi.append([list(map(int, input().split())) for _ in range(m)])
ans = 0
for i in range(1 << n):
    for j in range(n):
        if ((i >> j) & 1) == 1:
            for x,y in evi[j]:
                if ((i >> (x-1))&1) != y:
                    break
            else:
                continue
            break
    else:
        ans = max(ans,bin(i).count('1'))
print(ans)
# Original solution
n = int(eval(input()))
v = [[tuple(map(int, input().split()))for i in range(int(eval(input())))]
     for i in range(n)]

ans = 0
for i in range(2**n):
    f = [0] * n
    xy = []
    for j in range(n):
        if (i >> j) & 1:
            f[j] = 1
            xy.append(v[j])
    flag = True
    for xyi in xy:
        for x, y in xyi:
            #print(f,x,y,bin(i))
            if (i>>(x-1))&1 != y:
                flag = False
                break
    if flag:
        ans = max(ans, len(xy))
print(ans)


# Optimized solution
n = int(eval(input()))
v = [[tuple(map(int, input().split()))for i in range(int(eval(input())))]
     for i in range(n)]

ans = 0
for i in range(2**n):
    f = True
    a = 0
    for j in range(n):
        if (i >> j) & 1:
            if all(i >> (x - 1) & 1 == y for x, y in v[j]):
                a += 1
            else:
                f = False
                break
    if f:
        ans = max(ans, a)
print(ans)
# Original solution
n = int(eval(input()))
XY = []
ans = 0

for i in range(n):
    z = []
    
    for j in range(int(eval(input()))):
        x,y = list(map(int,input().split()))
        z.append([x,y])
        
    XY.append(z)
        
for i in range(2**n):
    honest = 0
    mujunn = 0
    
    for j in range(n):
        if (i>>j) & 1:
            honest += 1
            
            for k in XY[j]:
                x = k[0] - 1
                y = k[1]
                
                if (i>>x)&1 != y:
                    mujunn = 1
                
    if mujunn == 0:
        ans = max(ans,honest)
        
print(ans)

# Optimized solution
n = int(eval(input()))
XY = []
ans = 0

for i in range(n):
    z = []
    
    for j in range(int(eval(input()))):
        x,y = list(map(int,input().split()))
        z.append([x,y])
        
    XY.append(z)
        
for i in range(2**n):
    honest = 0
    mujunn = 0
    
    for j in range(n):
        if (i>>j) & 1:
            honest += 1
            
            for k in XY[j]:
                x = k[0] - 1
                y = k[1]
                
                if (i>>x)&1 != y:
                    mujunn = 1
                    break
                    
        if mujunn == 1:
            break
                
    if mujunn == 0:
        ans = max(ans,honest)
        
print(ans)
# Original solution
N = int(eval(input()))
T = [[-1] * N for _ in range(N)]
for i in range(N):
    for _ in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        T[i][x - 1] = y

ans = 0
for i in range(1 << N):
    is_kind = [i >> j & 1 for j in range(N)]
    found = True
    for j in range(N):
        if not is_kind[j]:
            continue
        for k in range(N):
            if j == k or T[j][k] == -1 or T[j][k] == is_kind[k]:
                continue
            found = False
    if found:
        ans = max(ans, sum(is_kind))
print(ans)


# Optimized solution
N = int(eval(input()))
T = [[-1] * N for _ in range(N)]
for i in range(N):
    for _ in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        T[i][x - 1] = y

ans = 0
for i in range(1 << N):
    is_kind = [i >> j & 1 for j in range(N)]
    found = True
    for j in range(N):
        if not is_kind[j]:
            continue
        for k in range(N):
            if j == k or T[j][k] == -1 or T[j][k] == is_kind[k]:
                continue
            found = False
        if not found:
            break
    if found:
        ans = max(ans, sum(is_kind))
print(ans)
# Original solution
N = int(eval(input()))
T = [[-1] * N for _ in range(N)]
for i in range(N):
    for _ in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        T[i][x - 1] = y

ans = 0
for i in range(1 << N):
    is_kind = [i >> j & 1 for j in range(N)]
    found = True
    for j in range(N):
        if not is_kind[j]:
            continue
        for k in range(N):
            if j == k or T[j][k] == -1 or T[j][k] == is_kind[k]:
                continue
            found = False
        if not found:
            break
    if found:
        ans = max(ans, sum(is_kind))
print(ans)


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

ans = 0
for i in range(1 << N):
    is_kind = [i >> j & 1 for j in range(N)]
    if all(not is_kind[j] or is_kind[x] == y for j, x ,y in T):
        ans = max(ans, sum(is_kind))
print(ans)
# Original solution
from itertools import product

n = int(eval(input()))

a = []
xy = []

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

ans = 0
for pat in product([1, 0], repeat=n):
    sat = True
    for i, bl in enumerate(pat):
        if bl:
            for x, y in xy[i]:
                x -= 1
                if pat[x] != y:
                    sat = False

    if sat:
        cnt = sum(pat)
        ans = max(ans, cnt)

print(ans)


# Optimized solution
from itertools import product

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

for _ in range(n):
    ea = int(eval(input()))
    new = []
    for _ in range(ea):
        x, y = list(map(int, input().split()))
        x -= 1
        new.append([x, y])

    xy.append(new)

ans = 0
for pat in product([1, 0], repeat=n):
    bl = True
    for i, e in enumerate(pat):
        if e:
            for x, y in xy[i]:
                if pat[x] != y:
                    bl = False

    if bl:
        ans = max(ans, sum(pat))

print(ans)