TnT/Multi_CodeNet4Repair huggingface dataset:
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):
N,M = map(int,input().split())
ks = []
for i in range(M):
  ks.append(list(map(int,input().split())))
p = list(map(int, input().split()))
c = 0

for i in range(2 ** N):
  sw = [0]*N
  for j in range(N):
    if ((i >> j) & 1):
      sw[j] = 1
  frg = True
  for j in range(M):
    a = ks[j][0]
    aa = 0
    for k in range(a):
      aa += sw[k+1]
    if aa%2 != p[j]:
      frg = False
  if frg:
    c += 1
    
print(c)

N,M = map(int,input().split())
ks = []
for i in range(M):
  ks.append(list(map(int,input().split())))
p = list(map(int, input().split()))
c = 0

for i in range(2 ** N):
  sw = [0]*N
  for j in range(N):
    if ((i >> j) & 1):
      sw[j] = 1
  frg = True
  for j in range(M):
    a = ks[j][0]
    aa = 0
    for k in range(1,a+1):
      aa += sw[ks[j][k]-1]
    if aa%2 != p[j]:
      frg = False
  if frg:
    c += 1
    
print(c)

Verdicts: Runtime Error

Accepted
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):
#from operater import itemgetter
from collections import Counter
import numpy as np
N=int(input())
c=[]
v=[]
ans=[]
c_v={}
for i in range(N):
    tmp=input().split()
    ans.append(tmp)
    c.append(tmp[0])
    v.append(int(tmp[1]))
    if tmp[0] in c_v.keys():
        c_v[tmp[0]].append(int(tmp[1]))
    else:
        c_v[tmp[0]]=[int(tmp[1])]
    
hoge=np.array(list(Counter(c).keys()))
huga=np.argsort(np.array(c))
for i in range(N):
    city=ans[i][0]
    if len(c_v[city])==1:
        print(huga[np.where(hoge==ans[i][0])][0]+1)
    else:
        tmp=np.array(c_v[city])
        h=np.argsort(tmp)[::-1]
        print(huga[np.where(hoge==ans[i][0])][0]+h[c_v[city].index(int(ans[i][1]))]+1)
        

from collections import Counter 
from collections import defaultdict
from collections import deque
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


n,m=input_list()
a=[input_list() for _ in range(m)]
p=input_list()
ans=0
for i in range(2**n):
    bit=bin(i)[2:].zfill(n)
    flag=True
    for num,each in enumerate(a):
        now=0
        light=each[1:]
        #print(light)
        for v in light:
            
            if bit[int(v)-1]=="1":
                now=1-now
        if now!=p[num]:
            flag=False
            break
    if flag:
        ans+=1
print(ans)





Verdicts: Runtime Error

Accepted
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):
n, m = map(int, input().split())
a = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
c = 0
for n in range(1 << n):
    for i, s in enumerate(a):
        if p[i] ^ sum(n >> s-1 & 1 for s_ in s) & 1:
            break
        else:
            c += 1
print(c)

n, m = map(int, input().split())
a = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
c = 0
for n in range(1 << n):
    for i, s in enumerate(a):
        if p[i] ^ sum(n >> s_-1 & 1 for s_ in s) & 1:
            break
        else:
            c += 1
print(c)

n, m = map(int, input().split())
s_lists = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
count = 0
for i in range(2**n):
  l = 1
  for p, S in zip(P, s_lists):
    l *= (sum([int(bin(i)[2:].zfill(n)[s-1]) for s in S]) % 2 == p)
  count += l
print(count)

Verdicts: Runtime Error

Wrong Answer

Accepted
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):
n,m = map(int,input().split())
s_lst = [list(map(int,input().split())) for i in range(m)]
k_lst = []
for i in range(m):
    k = s_lst.pop(s_lst[i][0])
    k_lst.append(k)
p_lst = list(map(int,input().split()))
answer = 0

for i in range(2**n): 
    on_lst =[0]*n
    flag = True
    for j in range(n):
        if (i>>j) & 1:
            on_lst[j] = 1
    for l in range(m): 
        number = 0
        s = s_lst[l]
        for sw in s:
            if on_lst[sw-1]==1:
                number += 1
        if number%2 != p[i]:
            flag = False
            break
    if flag:
        answer += 1

print(answer)

n,m = map(int,input().split())
s_lst = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
    del s_lst[i][0]
p_lst = list(map(int,input().split()))
answer = 0

for i in range(2**n): 
    on_lst =[0]*n
    flag = True
    for j in range(n):
        if (i>>j) & 1:
            on_lst[j] = 1
    for l in range(m): 
        number = 0
        s = s_lst[l]
        for sw in s:
            if on_lst[sw-1]==1:
                number += 1
        if number%2 != p_lst[l]:
            flag = False
            break
    if flag:
        answer += 1

print(answer)

Verdicts: Runtime Error

Accepted
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):
n,m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
res = 0

for i in range(2**n):
    ptn = format(i, 'b').rjust(n, '0')
    light = True
    for j in range(m):
        tmp = 0
        for n in range(1, s[j][0]+1):
            if ptn[s[j][n] - 1] == '1':
                tmp += 1
        if tmp%2 != p[j]:
            light = False
    if light:
        res += 1
print(res)

n,m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
res = 0

for i in range(2**n):
    ptn = format(i, 'b').rjust(n, '0')
    light = True
    for j in range(m):
        tmp = 0
        for k in range(1, s[j][0]+1):
            if ptn[s[j][k] - 1] == '1':
                tmp += 1
        if tmp%2 != p[j]:
            light = False
    if light:
        res += 1
print(res)

Verdicts: Runtime Error

Accepted
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):
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def create_bin_string(data, num):
    c_bin = "{:b}".format(data)
    switches = c_bin
    for _ in range(0, num-len(c_bin)):
        switches = "0" + switches
    return switches


def solve(N, M, data, Ps):
    lamp_sw_comb = list(map(lambda x: string_to_int(x), data))
    lamp_sw_p = string_to_int(Ps)

    count = 0
    for c in range(0, 2**N):
        switches = create_bin_string(c, N)
        print(switches)

        are_all_light = True
        for i, lamp_sw in enumerate(lamp_sw_comb):
            on_num = 0
            for j, sw in enumerate(lamp_sw):
                if j == 0:
                    continue
                if switches[sw-1] == "1":
                    on_num += 1
            if on_num % 2 != lamp_sw_p[i]:
                are_all_light = False
                break

        if are_all_light:
            count += 1
    return count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    data = inputs(M)
    Ps = input()
    ret = solve(N, M, data, Ps)
    print(ret)


import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def create_bin_string(data, num):
    c_bin = "{:b}".format(data)
    switches = c_bin
    for _ in range(0, num-len(c_bin)):
        switches = "0" + switches
    return switches


def solve(N, M, data, Ps):
    lamp_sw_comb = list(map(lambda x: string_to_int(x), data))
    lamp_sw_p = string_to_int(Ps)

    count = 0
    for c in range(0, 2**N):
        switches = create_bin_string(c, N)

        are_all_light = True
        for i, lamp_sw in enumerate(lamp_sw_comb):
            on_num = 0
            for j, sw in enumerate(lamp_sw):
                if j == 0:
                    continue
                if switches[sw-1] == "1":
                    on_num += 1
            if on_num % 2 != lamp_sw_p[i]:
                are_all_light = False
                break

        if are_all_light:
            count += 1
    return count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    data = inputs(M)
    Ps = input()
    ret = solve(N, M, data, Ps)
    print(ret)


Verdicts: Wrong Answer

Accepted
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):
n, m = map(int, input().split())
light = []
for _ in range(m):
  s_map = map(int, input().split())
  next(s_map)
  indices = [s-1 for s in s_map]
  light.append(int('0b' + ''.join(number)))
p = list(map(int, input().split()))
count = 0
for i in range(1 << n):
  list_i = [int(bit) for bit in format(i, '0{}b'.format(n))]
  flag = True
  for j in range(m):
    on = 0
    for idx in indices:
      on ^= list_i[idx]
    if on != p[j]:
      flag = False
      break
  if flag:
    count += 1
print(count)

n, m = map(int, input().split())
indices = []
for _ in range(m):
  s_map = map(int, input().split())
  next(s_map)
  indices.append([s-1 for s in s_map])
p = list(map(int, input().split()))
count = 0
for i in range(1 << n):
  list_i = [int(bit) for bit in format(i, '0{}b'.format(n))]
  flag = True
  for j in range(m):
    on = 0
    for idx in indices[j]:
      on ^= list_i[idx]
    if on != p[j]:
      flag = False
      break
  if flag:
    count += 1
print(count)

Verdicts: Runtime Error

Accepted
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):
# -*- coding:utf-8 -*-
from itertools import product

def solve():
    N, M = list(map(int, input().split()))
    K, S = [], []
    for _ in range(M):
        _in = list(map(int, input().split()))
        K.append(_in[0])
        S.append(_in[1:])
    P = list(map(int, input().split()))

    all_stats = product((0,1), repeat=N)
    ans = 0
    for stat in all_stats:
        is_ok = True
        for switch_i, switch in enumerate(S):
            on_num = 0
            for i in range(len(switch)):
                if switch[i] == stat[i]:
                    on_num += 1
            if on_num%2 != P[switch_i]:
                is_ok = False
                break
        if is_ok:
            ans += 1
    print(ans)

if __name__ == "__main__":
    solve()


# -*- coding:utf-8 -*-


def solve():
    N, M = list(map(int, input().split()))
    denkyu = []
    for i in range(M):
        inputs = list(map(int, input().split()))
        k, Ss = inputs[0], inputs[1:]
        denkyu.append(Ss)
    Ps = list(map(int, input().split()))

    
    ans = 0
    for bits in range(2**N): # 1024
        light = 0  
        for j in range(M): # 10
            total = 0
            for sw in denkyu[j]: # 10
                if (bits>>(sw-1)&1):
                    total += 1
            if total%2 == Ps[j]:
                light += 1
            else:
                break
        if light == M:
            ans += 1
    print(ans)


if __name__ == "__main__":
    solve()


Verdicts: Wrong Answer

Accepted
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):













n, m = map(int, input().split())


k = []
s = []

for _ in range(m):
    tmp = tuple(map(int, input().split()))
    k.append(tmp[0])
    s.append(set(tmp[1:-1]))
 
p = tuple(map(int, input().split()))
 
# print(k, s, p, sep="\n")

ans = 0


for i in range(2 ** n):
    
    light_on = 0
 
    
    for j in range(m):
        switch_on = 0
 
        for k in range(n):
            
            if (i >> k) & 1:
                
                
                
                if k + 1 in s[j]:
                    switch_on += 1
 
        
        if switch_on % 2 == p[j]:
            light_on += 1
 
    
    if light_on == m:
        # print(bin(i))
        ans += 1
 
print(ans)














n, m = map(int, input().split())


k = []
s = []

for _ in range(m):
    tmp = tuple(map(int, input().split()))
    k.append(tmp[0])
    s.append(set(tmp[1:tmp[0] + 1]))
 
p = tuple(map(int, input().split()))
 
# print(k, s, p, sep="\n")

ans = 0


for i in range(2 ** n):
    
    light_on = 0
 
    
    for j in range(m):
        switch_on = 0
 
        for k in range(n):
            
            if (i >> k) & 1:
                
                
                
                if k + 1 in s[j]:
                    switch_on += 1
 
        
        if switch_on % 2 == p[j]:
            light_on += 1
 
    
    if light_on == m:
        # print(bin(i))
        ans += 1
 
print(ans)

Verdicts: Wrong Answer

Accepted
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):
n, m = map(int, input().split())

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = map(int, input().split())

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    for s in d:
      count += switch_states[s-1]
      if count % 2 == P[di]:
        ans += 1
        
        
print(ans)

N, M = map(int, input().split())

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = map(int, input().split())

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    for s in d:
      count += switch_states[s-1]
      if count % 2 == P[di]:
        ans += 1
        
        
print(ans)

N, M = map(int, input().split())

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = list(map(int, input().split()))

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    
    for s in d:
      count += switch_states[s-1]
      
    if count % 2 != P[di]:
      ans -= 1
      break

  ans += 1
        
        
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
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):
import numpy as np
N,M= list(map(int, input().split()))
K = []
S=[]
state_S = np.zeros(N)
for m  in range(M):
    _input = list(map(int, input().split()))
    K.append(_input[0])
    S.append(np.array(_input[1:]))
P = list(map(int, input().split()))
ans=0
for i in range(N ** 2):
    pattern= np.array([i >> bit & 1 for bit in range(N)])
    if all(sum(pattern[K[j] -1 ]) % 2 == P[j] for j in range(M)):
        ans += 1
print(ans)





import numpy as np
N,M= list(map(int, input().split()))
K = []
S=[]
state_S = np.zeros(N)
for m  in range(M):
    _input = list(map(int, input().split()))
    K.append(_input[0])
    S.append(np.array(_input[1:]))
P = list(map(int, input().split()))
ans=0
for i in range(2 ** N):
    pattern= np.array([i >> bit & 1 for bit in range(N)])
    if all(np.sum(pattern[S[j] -1 ]) % 2 == P[j] for j in range(M)):
        ans += 1
print(ans)











Verdicts: Runtime Error

Accepted
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):
N, M = int(input().split())  


SSS = [list(map(int, input().split()))[1:] for i in range(M)]
P = list(map(int, input().split()))

ans = 0

for i in range(1 << N):  
    for mask in range(M):
        ans_2 = 0
        for s in SSS[mask]:
            if (1 << s-1) & i != 0:
                ans_2 += 1

        if ans_2 % 2 != P[m]:
            break
    else:
        ans += 1

print(ans)
        

N, M = int(input().split())  


SSS = [list(map(int, input().split()))[1:] for i in range(M)]
P = list(map(int, input().split()))

ans = 0

for i in range(1 << N):  
    for mask in range(M):
        ans_2 = 0
        for s in SSS[mask]:
            if (1 << s-1) & i != 0:
                ans_2 += 1

        if ans_2 % 2 != P[mask]:
            break
    else:
        ans += 1

print(ans)


N, M = map(int, input().split())


S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

# print(S)
# print(P)

ans = 0

for i in range(1 << N):
    # print(i)
    for m in range(M):
        cnt = 0
        for s in S[m]:  
            if i & (1 << (s-1)) != 0:
                cnt += 1
        if cnt % 2 != P[m]:
            break
      
        ans += 1

print(ans)



# d = 4

#     print("mask =", mask)






N, M = map(int, input().split())  

connect_infos = []

for i in range(M):
    k, *S = list(map(lambda x: int(x)-1, input().split()))
    connect_infos.append(S)

# print(connect_info)

P = list(map(int, input().split()))
# print(P)


switches_status = [[] for _ in range(1 << N)]
# print(switches_status)
for mask in range((1 << N)):  
    for i in range(N):
        switches_status[mask].append((mask >> i) & 1)

# print(switches_status)

ans = 0

for status in switches_status:
    shine = 0
    
    for i, connect_info in enumerate(connect_infos):
        
        on_count = 0
        for j in connect_info:
            on_count += status[j]
        
        if on_count % 2 == P[i]:
            shine += 1
    if shine == M:  
        ans += 1

print(ans)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
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):
# n=int(inputfile.readline())
# a,b=map(int, inputfile.readline().split())
# c=list(map(int, inputfile.readline().split()))


# a=100
# b=0.987654321

# 000100-0.987654

import math
import sys

inputfile = open("input.txt")
N, M=map(int, inputfile.readline().split())




bulb_list = [0 for _ in range(N)]

for bulb_idx in range(M):
    switches = list(map(int, inputfile.readline().split()))
    bulb_bit = 1 << bulb_idx 

    
    for sw in switches[1::]:
        sw_idx = (sw - 1) 
        bulb_list[sw_idx] = bulb_list[sw_idx] | bulb_bit

bulb_conds = list(map(int, inputfile.readline().split()))

bulb_cond = 0
for i, bc in enumerate(bulb_conds):
    bulb_cond |= bc << i

light_num = 0



for bit_ptn in range(1 << N):
    t = 0 
    for i in range(N):
        if bit_ptn >> i & 1:
            t = t ^ bulb_list[i]
    if t == bulb_cond:
        light_num += 1

print(light_num)


import sys




# xor (1,1) = 0, (0, 0) = 0 / (1, 0) = 1, (0, 1) = 1
if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    L = [list(map(int,list(sys.stdin.readline().split()))) for i in range(M)]
    cond = list(map(int, sys.stdin.readline().split()))

    cnt = 0
    for sw_bit in range(1 << N):
        flag = True
        for l, c in zip(L, cond):
            bit = 0
            for e in l[1::]:
                bit |= (1 << (e - 1))
            
            bit &= sw_bit
            if bin(bit).count("1") % 2 != c:
                flag = False
                break
        if flag:
            cnt += 1
    print(cnt)

Verdicts: Runtime Error

Accepted
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):
import itertools

N, M = map(int, input().split())
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    S.append([tmp[1:]])
P = list(map(int, input().split()))


origin_list = [0, 1]
all_way = []
for i in itertools.product(origin_list, repeat=N):
    all_way.append(i)

ans = 0
for way in all_way:
    light = 0
    for i, s in enumerate(S):
        small_sum = 0
        for ss in s:
            if way[ss - 1] == 1:
                small_sum += 1
        if small_sum % 2 == P[i]:
            light += 1
    if light == M:
        ans += 1

print(ans)

import itertools

N, M = map(int, input().split())
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    S.append([tmp[1:]])
P = list(map(int, input().split()))


origin_list = [0, 1]
all_way = []
for i in itertools.product(origin_list, repeat=N):
    all_way.append(i)
print(all_way)

ans = 0
for way in all_way:
    light = 0
    for i, s in enumerate(S):
        small_sum = 0
        for ss in s:
            if way[ss - 1] == 1:
                small_sum += 1
        if small_sum % 2 == P[i]:
            light += 1
    if light == M:
        ans += 1

print(ans)

import itertools

N, M = map(int, input().split())
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    S.append([tmp[1:]])
P = list(map(int, input().split()))


origin_list = [0, 1]
all_way = []
for i in itertools.product(origin_list, repeat=N):
    all_way.append(i)

ans = 0
for way in all_way:
    light = 0
    for i, s in enumerate(S):
        small_sum = 0
        for ss in s:
            for sss in ss:
                if way[sss - 1] == 1:
                    small_sum += 1
            if small_sum % 2 == P[i]:
                light += 1
        if light == M:
            ans += 1

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
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):
n,m=map(int,input().split())
s=[]
count=0
for i in range(m):
    tmp=list(map(int,input().split()))
    s.append(tmp[1:])

p=list(map(bool,input().split()))
p=list(map(lambda x:not x,p))

for i in range(2**n):
    tmp_p=p[:]#shallow copy
    for j in range(n):
        if i >> j & 1:
            for k in range(m):
                if j+1 in s[k]:
                    tmp_p[k]^=True#toggle

    if all(tmp_p):
        count+=1
        print(bin(i))
print(count)


n,m=map(int,input().split())
s=[]
count=0
for i in range(m):
    tmp=list(map(int,input().split()))
    s.append(tmp[1:])

p=list(map(int,input().split()))
p=list(map(bool,p))
p=list(map(lambda x:not x,p))

for i in range(2**n):
    tmp_p=p[:]#shallow copy
    for j in range(n):
        if i >> j & 1:
            for k in range(m):
                if j+1 in s[k]:
                    tmp_p[k]^=True#toggle

    if all(tmp_p):
        count+=1
print(count)


Verdicts: Wrong Answer

Accepted
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):
import numpy as np
from itertools import product

def main():
    n, m = [int(i) for i in input().split()]
    sw = np.zeros((m, n), int)
    for i in range(m):
        for s in input().split()[1:]:
            sw[i][int(s)-1] = 1

    p = np.array([int(i) for i in input().split()])
    print(sw)
    res = 0
    for t in product((0, 1), repeat=n):
        stat = np.array(t)
        if np.array_equal(p, np.dot(sw, stat) % 2):
            res += 1
    print(res)


if __name__ == '__main__':
    main()



import numpy as np
from itertools import product

def main():
    n, m = [int(i) for i in input().split()]
    sw = np.zeros((m, n), int)
    for i in range(m):
        for s in input().split()[1:]:
            sw[i][int(s)-1] = 1

    p = np.array([int(i) for i in input().split()])
    res = 0
    for t in product((0, 1), repeat=n):
        stat = np.array(t)
        if np.array_equal(p, np.dot(sw, stat) % 2):
            res += 1
    print(res)


if __name__ == '__main__':
    main()



Verdicts: Wrong Answer

Accepted
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):
N,M = map(int,input().split())
lis = [None]*M
for i in range(M):
    lis[i] = list(map(int,input().split()))
p = list(map(int,input().split()))
answer = 0

for bit in range(1<<N):
    count =[]
    for i in range(N): #make bit
        mask = 1<<i
        if mask&bit:
            count.append(1)
        else:
            count.append(0)
        #process
    for j in range(M):
        temp = 0
        for k in range(lis[j][0]):
            temp+=count[lis[j][k+1]-1]
        if temp%2 != p[j]:
            break
    else:
        answer+=1
        print(count)
print(answer)


N,M = map(int,input().split())
lis = [None]*M
for i in range(M):
    lis[i] = list(map(int,input().split()))
p = list(map(int,input().split()))
answer = 0

for bit in range(1<<N):
    count =[]
    for i in range(N): #make bit
        mask = 1<<i
        if mask&bit:
            count.append(1)
        else:
            count.append(0)
        #process
    for j in range(M):
        temp = 0
        for k in range(lis[j][0]):
            temp+=count[lis[j][k+1]-1]
        if temp%2 != p[j]:
            break
    else:
        answer+=1
print(answer)


Verdicts: Wrong Answer

Accepted
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):
I=lambda:list(map(int,input().split()))
n,m=I()
s=eval('I(),'*m)
p=I()
a=0
r=range
for i in r(1<<n):
 c=[0]*m
 for j in r(n):
  for k in r(m):c[k]+=i>>j&j+1in s[k][1:]
 a+=all(j==i%2for i,j in zip(c,p))
print(a)

(n,m),*s,p=[list(map(int,t.split()))for t in open(0)]
a=0
for i in range(1<<n):
 c=[0]*m
 for j in range(n*m):c[j%m]^=i>>j//m&(j//m+1in s[j%m][1:])
 a+=c==p
print(a)

Verdicts: Wrong Answer

Accepted
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):
N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(list(map(int, input().split()))[1:])
p = map(int, input().split())
ans = 0
for bit in range(1 << N):
    for m in range(M):
        if p[m] != ([str(bit).zfill(N)[s-1] for s in S[m]].count('1') % 2):
            break
    else:
        ans += 1
print(ans)


N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
    for m in range(M):
        if sum([bit & (1 << (s-1)) > 0 for s in S[m]]) % 2 != P[m]:
            break
    else:
        ans += 1
print(ans)


Verdicts: Runtime Error

Accepted
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):
n, m = map(int, input().split())
ks = [[int(i) for i in input().split()][1:] for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** n):
    for j in range(m):
        cnt = 0
        for k in range(n):
            if i >> j & 1 and k + 1 in ks[j]:
                cnt += 1
        if cnt % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)

n, m = map(int, input().split())
ks = [[int(i) for i in input().split()][1:] for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** n):
    for j in range(m):
        cnt = 0
        for k in range(n):
            if i >> k & 1 and k + 1 in ks[j]:
                cnt += 1
        if cnt % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)

Verdicts: Wrong Answer

Accepted
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):
import itertools
 
N, M = map(int, input().split())
lights = []
for m in range(M):
  
  interpools mpzp(input())
    tmp = list(map(int, input().split()))
    lights.append(tmp[1:])
 
 
P = list(map(int, input().split()))
 
ans = 0
for product in list(itertools.product([0, 1], repeat=N)):
    for light in range(len(lights)):
        cnt = 0
        for l in lights[light]:
            cnt += product[l-1]
        if cnt % 2 != P[light]:
            break
        if light == len(lights) - 1:
            ans += 1
print(ans)

import itertools
 
N, M = map(int, input().split())
lights = []
for m in range(M):
  
  interpools mpzp(int,Input().spli
    tmp = list(map(int, input().split()))
    lights.append(tmp[1:])
 
 
P = list(map(int, input().split()))
 
ans = 0
for product in list(itertools.product([0, 1], repeat=N)):
    for light in range(len(lights)):
        cnt = 0
        for l in lights[light]:
            cnt += product[l-1]
        if cnt % 2 != P[light]:
            break
        if light == len(lights) - 1:
            ans += 1
print(ans)

import itertools
 
N, M = map(int, input().split())
lights = []
for m in range(M):
    tmp = list(map(int, input().split()))
    lights.append(tmp[1:])
    
    
 
 
P = list(map(int, input().split()))
 
ans = 0
for product in list(itertools.product([0, 1], repeat=N)):
    for light in range(len(lights)):
        cnt = 0
        for l in lights[light]:
            cnt += product[l-1]
        if cnt % 2 != P[light]:
            break
        if light == len(lights) - 1:
            ans += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
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):
N,M=map(int,input().split())
lights=[]
for i in range(M):
    k,*s=map(int,input().split())
    lights.append(list(map(lambda x:x-1,s)))
P=list(map(int,input().split()))
cnt=0
for b in range(1<<N):#bit
    flg=True
    for m in range(M):
        on_cnt=0
        for switch in lights[m]:
            if (b>>switch)&2:
                on_cnt+=1
        if on_cnt==0 or on_cnt%2 != P[m]:
            flg=False
    if flg:
       cnt+=1
print(cnt)       

def is_all_on(on_switches):
    on_cnt = 0
    for i in range(M):
        cnt = 0
        for on in on_switches:
            if on in lights[i]: 
                cnt += 1
        if cnt % 2 == P[i]:        
            on_cnt += 1
    return True if on_cnt == M else False        
            
N,M = map(int,input().split())
lights = []
for m in range(M):
    lights.append(list(map(lambda x:int(x) - 1,input().split()))[1:])
P = list(map(int,input().split()))
#print(lights)

ans = 0
for i in range(1 << N): 
    on_switches = []
    for j in range(N): 
        if ((i >> j) & 1) == 1: 
            on_switches.append(j) 
    if is_all_on(on_switches): ans += 1 
    #print(i,on_switches)    
print(ans)    
            

Verdicts: Wrong Answer

Accepted
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):
N,M=map(int,input().split())
A=[]
for i in range(M):
    A.append(list(map(int,input().split())))
P=list(map(int,input().split()))
ans=0
for i in range(2**N,2**(N+1)):
        B=bin(i)
        count=0
        for j in range(M):
            tet=0
            for l in range(A[j][0]):
                tet+=int(B[A[j][l+1]+2])
            if tet//2==P[j]:
                  count+=1
        if count==M:
            ans+=1
print(ans)
N,M=map(int,input().split())
A=[]
for i in range(M):
    A.append(list(map(int,input().split())))
P=list(map(int,input().split()))
ans=0
for i in range(2**N,2**(N+1)):
        B=bin(i)
        count=0
        for j in range(M):
            tet=0
            for l in range(A[j][0]):
                tet+=int(B[A[j][l+1]+2])
            if tet%2==P[j]:
                  count+=1
        if count==M:
            ans+=1
print(ans)


N,M=map(int,input().split())
A=[]
for i in range(M):
    A.append(list(map(int,input().split())))
P=list(map(int,input().split()))
ans=0
for i in range(2**N,2**(N+1)):
        B=bin(i)
        count=0
        for j in range(M):
            tet=0
            for l in range(A[j][0]):
                tet+=int(B[A[j][l+1]+2])
            if tet//2==P[j]:
                  count+=1
        if count==M:
            ans+=1
print(ans)

N,M=map(int,input().split())
A=[]
for i in range(M):
    A.append(list(map(int,input().split())))
P=list(map(int,input().split()))
ans=0
for i in range(2**N,2**(N+1)):
        B=bin(i)
        count=0
        for j in range(M):
            tet=0
            for l in range(A[j][0]):
                tet+=int(B[A[j][l+1]+2])
            if tet%2==P[j]:
                  count+=1
        if count==M:
            ans+=1
print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
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):
N, M = map(int, input().split())
X=[]
for i in range(M):
    X.append(list(map(int, input().split())))
P=list(map(int, input().split()))
ans=0

key='{:0'+str(N)+"b}"
for k in range(2**N):
    
    switch=list(key.format(k))
    for i in range(M):
        
        odd=1
		even=0
        if P[i]==1:
            odd=0
            for j in range(X[i][0]):
                odd+=int(switch[ X[i][j+1]-1] )
            if odd%2==0:
                break
            
        else:
            even=0
            for j in range(X[i][0]):
                even+=int(switch[ X[i][j+1]-1] )
            if even%2==1:
                break
    
    if odd%2==1 and even%2==0:
        ans+=1
        #print(X[i],switch,odd,even)
            
print(ans)






N, M = map(int, input().split())
X=[]
for i in range(M):
    X.append(list(map(int, input().split())))
P=list(map(int, input().split()))



ans=0
key='{:0'+str(N)+"b}"
for i in range(2**N):
    
    switch=list(key.format(i))
    ODD=1
    EVEN=1
    for i in range(M):
        if P[i]==1:
            odd=0
            for j in range(X[i][0]):
                odd+=int(switch[ X[i][j+1]-1] )
            if odd%2==0:
                break
            else:
                ODD*=odd
            
        else:
            even=0
            for j in range(X[i][0]):
                even+=int(switch[ X[i][j+1]-1] )
            if even%2==1:
                break
            else:
                EVEN*=even
                
    if ODD%2==1 and EVEN%2==0:
        ans+=1

print(ans)    
print(ans)

N, M = map(int, input().split())
X=[]
for i in range(M):
    X.append(list(map(int, input().split())))
P=list(map(int, input().split()))
ans=0

key='{:0'+str(N)+"b}"
for k in range(2**N):
    
    switch=list(key.format(k))
    for i in range(M):
        odd=1
        even=0
        if P[i]==1:
            odd=0
            for j in range(X[i][0]):
                odd+=int(switch[ X[i][j+1]-1] )
            if odd%2==0:
                break
            
        else:
            even=0
            for j in range(X[i][0]):
                even+=int(switch[ X[i][j+1]-1] )
            if even%2==1:
                break
    
    if odd%2==1 and even%2==0:
        ans+=1
        #print(X[i],switch,odd,even)
            
print(ans)






Verdicts: Runtime Error

Wrong Answer

Accepted
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):
import numpy as np
import itertools as ittr

def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        eb = np.asarray(e_ball)
        si = sw[eb - 1]
        
        if p[i] != (np.sum(si == 1) % 2):
            return False
    
    return True

N, M = map(int, input().split())

e_balls = []

for m in range(M):
    i = input().split()
    s = [int(si) for si in i[1:]]
    e_balls.append(s[:])

p = [int(pi) for pi in input().split()]

cnt = 0

for sw in ittr.product([0, 1], repeat = N)
    if test_switch(e_balls, sw, p):
        cnt += 1

print(cnt)

import numpy as np
import itertools as ittr

def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        si = sw[eb - 1]
        
        if p[i] != (np.sum(si == 1) % 2):
            return False
    
    return True

N, M = map(int, input().split())

e_balls = []

for m in range(M):
    i = input().split()
    s = [int(si) for si in i[1:]]
    e_balls.append(s[:])

p = [int(pi) for pi in input().split()]

cnt = 0

for sw in ittr.product([0, 1], repeat = N):
    if test_switch(e_balls, np.array(sw), p):
        cnt += 1

print(cnt)

import numpy as np
import itertools as ittr

def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        n_on = np.sum(sw[e_ball - 1])
        
        if p[i] != (n_on % 2):
            return False
    
    return True

N, M = map(int, input().split())

e_balls = []

for m in range(M):
    e_balls.append(np.asarray([int(si) for si in input().split()[1:]]))

p = [int(pi) for pi in input().split()]

cnt = 0

for sw in ittr.product([0, 1], repeat = N):
    if test_switch(e_balls, np.array(sw), p):
        cnt += 1

print(cnt)

Verdicts: Runtime Error

Runtime Error

Accepted
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):
n, m = map(int, input().split())
switch = [list(map(lambda x:int(x)-1, input().split()))[1:] for _ in range(m)]
rest = list(map(int, input().split()))
ans = 0
for bit in range(1<<n):
    on_sum = 0
    for j in range(m):
        for i in range(n):
            if bit >> i & 1 and i in switch[j]:
                on_sum += 1
        if on_sum % 2 != rest[j]:
            break
    ans += 1
print(ans)

n, m = map(int, input().split())
switch = [list(map(lambda x:int(x)-1, input().split()))[1:] for _ in range(m)]
rest = list(map(int, input().split()))
ans = 0
for bit in range(1<<n):
    for j in range(m):
        on_sum = 0
        for i in range(n):
            if bit >> i & 1 and i in switch[j]:
                on_sum += 1
        if on_sum % 2 != rest[j]:
            break
    else :
        ans += 1
print(ans)



Verdicts: Wrong Answer

Accepted
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):
N, M = map(int, input().split())
switch_list=[input().split() for i in range(M)]
switch_list=[[int(i[m+1]) for m in range(len(i)-1)] for i in switch_list]
P_list=input().split()
P_list=[int(i) for i in P_list]
for i in range(1 << z):
    switch=[0 for i in range(N)]
    for j in range(z):
        if ((i >> j) & 1) == 1:
            switch[j]=1
    count+=sum([sum([switch[m-1] for m in switch_list[x]])%2==P_list[x] for x in range(M)])==M
print(count)


N, M = map(int, input().split())
switch_list=[input().split() for i in range(M)]
switch_list=[[int(i[m+1]) for m in range(len(i)-1)] for i in switch_list]
P_list=input().split()
P_list=[int(i) for i in P_list]
count=0
z=N
for i in range(1 << z):
    switch=[0 for i in range(N)]
    for j in range(z):
        if ((i >> j) & 1) == 1:
            switch[j]=1
    count+=sum([sum([switch[m-1] for m in switch_list[x]])%2==P_list[x] for x in range(M)])==M
print(count)


Verdicts: Runtime Error

Accepted
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):
N, M = list(map(int, input().split()))
l = []
for i in range(M):
    ks = list(map(int, input().split()))
    k, s = ks[0], ks[1:]
    l.append(s)
    
p = list(map(int, input().split()))

ans = 0
for j in range(2**N):
    n = 0  
    for m in range(M):
        t = 0
        for sw in l[m]:
            if (j>>(sw-1)&1):
                print((j>>(sw-1)&1))
                t += 1
        if t%2 == p[m]:
            n += 1
        else:
            break
    if n == M:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
l = []
for i in range(M):
    ks = list(map(int, input().split()))
    k, s = ks[0], ks[1:]
    l.append(s)
    
p = list(map(int, input().split()))

ans = 0
for j in range(2**N):
    n = 0  
    for m in range(M):
        t = 0
        for sw in l[m]:
            if (j>>(sw-1)&1):
                t += 1
        if t%2 == p[m]:
            n += 1
        else:
            break
    if n == M:
        ans += 1
print(ans)
 

Verdicts: Wrong Answer

Accepted