Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
n,m = map(int,(input().split()))
bulb = [0]*m
p = [0]*m
j = 1
odd = 0
even = 0
for i in range(m):
    bulb[i] = list(map(int,input().split()))
p = list(map(int,input().split()))

for i in range(m):
    if not bulb[i][0]%2==p[i]:
        print(0)
        exit()
    elif bulb[i][0]%2==0:
        for j in range(0,bulb[i][0]+1,2):
            even = even + comb(bulb[i][0],j, exact=True)

        if len(bulb[i])==2:
            even = even/2
            
    else:
        for j in range(1,bulb[i][0]+1,2):
            odd = odd + comb(bulb[i][0],j, exact=True)

        if len(bulb[i])==2:
            odd = odd/2              
print(int(odd*even))

Fixed submission:
n,m = map(int,input().split())
res = 0

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

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1,len(q[i])):
            w = q[i][j]
            if s>>(w-1) &1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        res += 1
print(res)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
n,m = map(int,(input().split()))
bulb = [0]*m
p = [0]*m
j = 1
odd = 0
even = 0
for i in range(m):
    bulb[i] = list(map(int,input().split()))
p = list(map(int,input().split()))
 
for i in range(m):
    if not bulb[i][0]%2==p[i]:
        print(0)
        exit()
    elif bulb[i][0]%2==0:
        for j in range(0,bulb[i][0]+1,2):
            even = even + comb(bulb[i][0],j, exact=True)
            
        if len(bulb[i])==2:
            even = even/2
            
    else:
        for j in range(1,bulb[i][0]+1,2):
            odd = odd + comb(bulb[i][0],j, exact=True)
          
        if len(bulb[i])==2:
            odd = odd/2              
 
print(int(odd*even))

Fixed submission:
n,m = map(int,input().split())
res = 0

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

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1,len(q[i])):
            w = q[i][j]
            if s>>(w-1) &1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        res += 1
print(res)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
n,m = map(int,(input().split()))
bulb = [0]*m
p = [0]*m
j = 1
odd = 0
even = 0
for i in range(m):
    bulb[i] = list(map(int,input().split()))
p = list(map(int,input().split()))

for i in range(m):
    print('bulb='+str(bulb[i][0]))
    if not bulb[i][0]%2==p[i]:
        print(0)
        exit()
    elif bulb[i][0]%2==0:
        for j in range(0,bulb[i][0]+1,2):
            even = even + comb(bulb[i][0],j, exact=True)
            
        if len(bulb[i])==2:
            even = even/2
            
    else:
        for j in range(1,bulb[i][0]+1,2):
            odd = odd + comb(bulb[i][0],j, exact=True)
          
        if len(bulb[i])==2:
            odd = odd/2              

print(int(odd*even))

Fixed submission:
n,m = map(int,input().split())
res = 0

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

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1,len(q[i])):
            w = q[i][j]
            if s>>(w-1) &1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        res += 1
print(res)