Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
ans = 0
for i in range(1<<n):             
    sw = [False]*m                
    for j in range(m):            
        cnt = 0
        for k in range(1,len(s[j])):   
            if i>>s[j][k]&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):             
    sw = [False]*m                
    for j in range(m):            
        cnt = 0
        for k in range(1,len(s[j])):   
            if i>>s[j][k]&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
    
    sw = [False]*m
    
    for j in range(M):
        
        cnt = 0
        for k in range(1,len(s[j])):
            if i>>s[j][k]-1&1:
                cnt += 1

        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(M)) 
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
    
    sw = [False]*M
    
    for j in range(M):
        
        cnt = 0
        for k in range(1,len(s[j])):
            if i>>s[j][k]-1&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))
ans = 0
sw = [False]*m                
for j in range(m):            
    cnt = 0
    for k in range(1,len(s[j])):   
        if i>>s[j][k]-1&1:
            cnt += 1
    if cnt%2==p[j]:
        sw[j]=True
if all(sw):
    ans+=1
print(ans)

ans = 0
for i in range(1<<n):
    
    sw = [False]*M
    
    for j in range(M):
        
        cnt = 0
        for k in range(1,len(s[j])):
            if i>>s[j][k]-1&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))ans = 0
for i in range(1<<n):             
    sw = [False]*m                
    for j in range(m):            
        cnt = 0
        for k in range(1,len(s[j])):   
            if i>>s[j][k]&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
    
    sw = [False]*m
    
    for j in range(m):
        
        cnt = 0
        for k in range(1,len(s[j])):
            if i>>s[j][k]-1&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted