Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
k = []
s = []
for _ in range(M):
    std_in = list(map(int, input().split()))
    k.append(std_in[0])
    for i in range(std_in[0]):
        std_in[i+1] -= 1
    s.append(std_in[1:])
p = [int(i) for i in input().split()]

switches = [0] * N

def judge_bulbs(switches):
    for i in range(M):

        k_sum = 0
        for ki in range(k[i]):
            k_sum += switches[ki]

        if k_sum % 2 == p[i]:
            continue
        else:
            return False
    return True

def solve(idx, switches):
    if idx == N:
        if judge_bulbs(switches):
            return 1
        else:
            return 0

    ans = 0
    switches = switches.copy()
    
    ans += solve(idx+1, switches)

    switches[idx] = 1
    ans += solve(idx+1, switches)
    return ans

print(solve(0, switches))





Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
s = [LIST()[1:] for _ in range(M)]
p = LIST()

ans = 0
for x in product([0, 1], repeat=N):
    for i in range(M):
    	cnt = 0
    	for n in s[i]:
    		if x[n-1] == 1:
    			cnt += 1
    	if cnt%2 != p[i]:
    		break
    else:
    	ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc128/tasks/abc128_c

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

switches = [0] * N

def judge_bulbs(switches):
    for i in range(M):

        k_sum = 0
        for ki in range(k[i]):
            k_sum += switches[ki]

        if k_sum % 2 == p[i]:
            continue
        else:
            return False
    return True

def solve(idx, switches):
    if idx == N:
        if judge_bulbs(switches):
            return 1
        else:
            return 0

    ans = 0
    switches = switches.copy()
    
    ans += solve(idx+1, switches)

    switches[idx] = 1
    ans += solve(idx+1, switches)
    return ans

print(solve(0, switches))





Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
s = [LIST()[1:] for _ in range(M)]
p = LIST()

ans = 0
for x in product([0, 1], repeat=N):
    for i in range(M):
    	cnt = 0
    	for n in s[i]:
    		if x[n-1] == 1:
    			cnt += 1
    	if cnt%2 != p[i]:
    		break
    else:
    	ans += 1
print(ans)