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?

-----Constraints-----
 - 1 \leq N, M \leq 10
 - 1 \leq k_i \leq N
 - 1 \leq s_{ij} \leq N
 - s_{ia} \neq s_{ib} (a \neq b)
 - p_i is 0 or 1.
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N M
k_1 s_{11} s_{12} ... s_{1k_1}
:
k_M s_{M1} s_{M2} ... s_{Mk_M}
p_1 p_2 ... p_M

-----Output-----
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs.

-----Sample Input-----
2 2
2 1 2
1 2
0 1

-----Sample Output-----
1

 - Bulb 1 is lighted when there is an even number of switches that are "on" among the following: Switch 1 and 2.
 - Bulb 2 is lighted when there is an odd number of switches that are "on" among the following: Switch 2.
There are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.

Difficulty: EASY

Solutions:
(n, m) = map(int, input().split(' '))
ks = [list(map(int, input().split(' '))) for i in range(m)]
p = list(map(int, input().split(' ')))
total = 0
for i in range(2 ** n):
	count = 0
	den = [0 for i in range(m + 1)]
	for j in range(n):
		if i >> j & 1:
			for k in range(m):
				if j + 1 in ks[k][1:]:
					den[k + 1] += 1
	for j in range(m):
		if den[j + 1] % 2 == p[j]:
			count += 1
	if count == m:
		total += 1
print(total)


(N, M) = map(int, input().split())
X = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
for i in range(M):
	del X[i][0]
count = 0
for i in range(2 ** N):
	check = True
	for j in range(M):
		on = 0
		for k in X[j]:
			if i >> k - 1 & 1 == 1:
				on += 1
		if on % 2 != p[j]:
			check = False
	if check:
		count += 1
print(count)


(n, m) = map(int, input().split())
k = [0] * m
s = [0] * m
for i in range(m):
	tmp = list(map(int, input().split()))
	k[i] = tmp[0]
	s[i] = tmp[1:]
p = list(map(int, input().split()))
res = 0
for bit in range(2 ** n):
	for i in range(m):
		cnt = 0
		for sw in s[i]:
			if bit >> sw - 1 & 1:
				cnt += 1
		if cnt % 2 != p[i]:
			break
	else:
		res += 1
print(res)


(n, m) = map(int, input().split())
S = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
ans = 0
for b in range(2 ** n):
	onswitch = [i + 1 for i in range(n) if b >> i & 1]
	if all((sum((o in s for o in onswitch)) % 2 == p for (s, p) in zip(S, P))):
		ans += 1
print(ans)


(n, m) = map(int, input().split())
swl = [list(map(int, input().split())) for _ in range(m)]
pl = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	sw = [0] * n
	light_cnt = 0
	for j in range(n):
		if i >> j & 1:
			sw[j] += 1
	for j in range(m):
		wl = swl[j][1:]
		sw_cnt = 0
		for wi in wl:
			if sw[wi - 1] == 1:
				sw_cnt += 1
		if sw_cnt % 2 == pl[j]:
			light_cnt += 1
	if light_cnt == m:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
s = []
for i in range(m):
	ks = list(map(int, input().split()))
	s.append(ks[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	for j in range(m):
		cnt = 0
		for k in s[j]:
			if i & 1 << k - 1:
				cnt += 1
		if cnt % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
result = 0
for i in range(2 ** n):
	flag = 1
	for j in range(m):
		count = 0
		for k in range(s[j][0]):
			if i >> s[j][k + 1] - 1 & 1 == 1:
				count += 1
		if count % 2 != p[j]:
			flag = 0
	if flag == 1:
		result += 1
print(result)


(n, m) = map(int, input().split())
L = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	on = bin(i)[2:].zfill(n)
	for (s, p) in zip(L, P):
		if sum((int(on[sij - 1]) for sij in s)) % 2 != p:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
b = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	c = []
	q = True
	for j in range(n):
		c.append(i >> j & 1)
	for k in range(m):
		p = 0
		for l in range(1, a[k][0] + 1):
			if c[a[k][l] - 1] == 1:
				p += 1
		if p % 2 != b[k]:
			q = False
	if q:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
S = []
for _ in range(m):
	s = list(map(int, input().split()))
	S.append(s[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	for k in range(m):
		sw = 0
		for j in range(n):
			if i >> j & 1 and j + 1 in S[k]:
				sw += 1
		if sw % 2 != p[k]:
			break
	else:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
Ss = [list(map(int, input().split()[1:])) for _ in range(M)]
p = list(map(int, input().split()))
cnt = 0
for L in range(pow(2, N)):
	for (pi, s) in zip(p, Ss):
		x = pi
		for si in s:
			x ^= (L & 1 << si - 1 != 0) * 1
		if x != 0:
			break
	else:
		cnt += 1
print(cnt)


from itertools import product
(N, M) = list(map(int, input().split()))
bulbs = [list([int(x) - 1 for x in input().split()]) for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for x in product([0, 1], repeat=N):
	is_on = [0] * M
	for i in range(M):
		(k, *switches) = bulbs[i]
		cnt = sum((x[s] for s in switches))
		if cnt % 2 == P[i]:
			is_on[i] = 1
	if all(is_on):
		ans += 1
print(ans)


3
import sys
input = lambda : sys.stdin.readline().strip()
(n, m) = [int(x) for x in input().split()]
s = [[int(x) - 1 for x in input().split()][1:] for i in range(m)]
p = [int(x) for x in input().split()]
print(sum((1 for mask in range(1 << n) if all((sum((mask >> bulb & 1 for bulb in s[i])) % 2 == p[i] for i in range(m))))))


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for num in range(1 << n):
	all = True
	for M in range(m):
		swt = 0
		for k in s[M][1:]:
			if num & 1 << k - 1:
				swt += 1
		if swt % 2 != p[M]:
			all = False
			break
	if all:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
K = [list(map(int, input().split())) for _ in range(m)]
P = list(map(int, input().split()))
ans = 0
for bits in range(2 ** n):
	ok = True
	for (i, k) in enumerate(K):
		ok = ok and sum((bits >> s - 1 & 1 for s in k[1:])) % 2 == P[i]
	if ok:
		ans += 1
print(ans)


import itertools
(n, m) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
sss = 0
for c in itertools.product([0, 1], repeat=n):
	ans = 0
	for i in range(m):
		cnt = 0
		for j in range(l[i][0]):
			if c[l[i][j + 1] - 1] == 1:
				cnt += 1
		if cnt % 2 == p[i]:
			ans += 1
	if ans == m:
		sss += 1
print(sss)


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


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


((n, m), *s, p) = [list(map(int, t.split())) for t in open(0)]
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 + 1 in s[k][1:])
	a += all((j == i % 2 for (i, j) in zip(c, p)))
print(a)


import copy

def dfs(i, lst):
	nonlocal ans
	if i == n:
		ans.append(lst)
		return
	tmp1 = copy.copy(lst)
	tmp1.append(0)
	dfs(i + 1, tmp1)
	tmp2 = copy.copy(lst)
	tmp2.append(1)
	dfs(i + 1, tmp2)
(n, m) = map(int, input().split())
ans = []
tmp = [0]
dfs(0, tmp)
s = []
k = []
for i in range(m):
	tmp = list(map(int, input().split()))
	k.append(tmp[0])
	s.append(tmp[1:])
p = list(map(int, input().split()))
cnt = 0
for i in range(len(ans)):
	cnt_i = 0
	for mi in range(m):
		sum_s = 0
		for ki in range(len(s[mi])):
			sum_s += ans[i][s[mi][ki]]
		if sum_s % 2 == p[mi]:
			cnt_i += 1
	if cnt_i == m:
		cnt += 1
print(cnt)


(n, m) = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
res = 0
for i in range(2 ** n):
	t = bin(i + 2 ** n)[3:]
	judge = True
	for j in range(m):
		l = 0
		for k in ks[j][1:]:
			if t[k - 1] == '1':
				l += 1
		if l % 2 == p[j]:
			continue
		else:
			judge = False
			break
	if judge:
		res += 1
print(res)


(N, M) = map(int, input().split())
A = [[0 for _ in range(N)] for _ in range(M)]
for i in range(M):
	S = list(map(int, input().split()))
	for j in S[1:]:
		A[i][j - 1] = 1
P = list(map(int, input().split()))
ans = 0
for bit in range(2 ** N):
	b = bin(bit)[2:].zfill(N)
	X = [0] * M
	for i in range(M):
		for j in range(N):
			if A[i][j] == 1 and b[j] == '1':
				X[i] = (X[i] + 1) % 2
	tmp = 0
	for i in range(M):
		if P[i] == X[i]:
			tmp += 1
	if tmp == M:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
k = [0] * m
s = [[] for _ in range(m)]
for i in range(m):
	(k[i], *s[i]) = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	res = 0
	for a in range(m):
		tmp = p[a] ^ 1
		for j in s[a]:
			if i >> j - 1 & 1:
				tmp ^= 1
		res += tmp
	if res == m:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
S = []
for i in range(M):
	(k, *s) = list(map(int, input().split()))
	S.append(s)
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	if all([sum([i & 2 ** (n - 1) > 0 for n in S[m]]) % 2 == P[m] for m in range(M)]):
		ans += 1
print(ans)


def II():
	return int(input())

def MII():
	return list(map(int, input().split()))

def LII():
	return list(map(int, input().split()))

def main():
	(N, M) = MII()
	s = []
	for _ in range(M):
		s.append(list(map(int, input().split()))[1:])
	p = LII()
	ans = 0
	for i in range(2 ** N, 2 ** (N + 1)):
		b = bin(i)[3:]
		t = [0] * M
		for (j, sj) in enumerate(s):
			for (k, bi) in enumerate(list(b)):
				if bi == '1' and k + 1 in sj:
					t[j] += 1
			if t[j] % 2 != p[j]:
				ans -= 1
				break
		ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, m) = list(map(int, input().split()))
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	light = 0
	for (ki, j) in enumerate(k):
		switch = 0
		for s in j[1:]:
			if i >> s - 1 & 1:
				switch += 1
		if switch % 2 == p[ki]:
			light += 1
	if light == m:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
c = 0
for _ in range(2 ** n):
	s = str(bin(_))[2:].zfill(n)
	f = 1
	for i in range(m):
		a = 0
		for j in range(1, k[i][0] + 1):
			a += int(s[k[i][j] - 1])
		if a % 2 != p[i]:
			f = 0
			break
	if f:
		c += 1
print(c)


(N, M) = map(int, input().split())
A = [0] * M
for i in range(M):
	A[i] = list(map(int, input().split()))
P = list(map(int, input().split()))
F = 0
for i in range(2 ** N):
	E = 0
	Sui = [0] * N
	for j in range(N):
		if i >> j & 1:
			Sui[j] += 1
	for k in range(M):
		D = 0
		for l in range(1, A[k][0] + 1):
			if Sui[A[k][l] - 1] == 1:
				D += 1
		if D % 2 == P[k]:
			E += 1
	if E == M:
		F += 1
print(F)


(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 n in range(2 ** N):
	l = 1
	for (p, S) in zip(P, S_lists):
		l *= sum([int(bin(n)[2:].zfill(N)[s - 1]) for s in S]) % 2 == p
	count += l
print(count)


(N, M) = list(map(int, input().split()))
K = {i: [] for i in range(M)}
for i in range(M):
	t = list(map(int, input().split()))
	for j in range(1, len(t)):
		K[i].append(t[j] - 1)
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	switch = [False] * N
	for j in range(N):
		if i >> j & 1:
			switch[j] = True
	isok = True
	for m in range(M):
		t = 0
		for k in K[m]:
			if switch[k]:
				t += 1
		if t % 2 != P[m]:
			isok = False
	if isok:
		ans += 1
print(ans)


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


(N, M) = map(int, input().split())
S = []
for i in range(M):
	ks = list(map(int, input().split()))
	S.append(sum((1 << s - 1 for s in ks[1:])))
p = list(map(int, input().split()))
ans = 0
for state in range(2 ** N):
	on = True
	for m in range(M):
		on = bin(S[m] & state).count('1') % 2 == p[m]
		if not on:
			break
	ans += on
print(ans)


(N, M) = map(int, input().split())
S = [tuple(map(int, input().split()[1:])) for i in range(M)]
P = list(map(int, input().split()))
ans = 0
for b in range(1 << N):
	for (i, s) in enumerate(S):
		c = 0
		for t in s:
			if b & 1 << t - 1:
				c += 1
		if c % 2 != P[i]:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
a = 0
for bit in range(1 << n):
	for j in range(m):
		c = 0
		for k in s[j][1:]:
			if bit & 1 << k - 1:
				c += 1
		if c % 2 != p[j]:
			break
	else:
		a += 1
print(a)


(n, m) = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
(*p,) = map(int, input().split())
print(sum([all([sum([i >> k - 1 for k in s[j]]) % 2 == p[j] for j in range(m)]) for i in range(2 ** n)]))


(n, m) = map(int, input().split())
S = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
cnt = 0
for i in range(2 ** n):
	Q = 0
	switch = set([i + 1 for (i, j) in enumerate(format(i, 'b').zfill(n)[::-1]) if j == '1'])
	for (k, j) in enumerate(S):
		if len(switch & set(j)) % 2 == P[k]:
			Q += 1
	if Q == m:
		cnt += 1
print(cnt)


from itertools import product
(n, m) = map(int, input().split())
k = []
s = []
for _ in range(m):
	(a, *b) = map(int, input().split())
	k.append(a)
	s.append(b)
p = list(map(int, input().split()))
print(sum((all((sum((i[b - 1] for b in a)) % 2 == x for (a, x) in zip(s, p))) for i in product((0, 1), repeat=n))))


def inpl():
	return list(map(int, input().split()))
(N, M) = inpl()
L = [0] * M
for i in range(M):
	for s in inpl()[1:]:
		L[i] += pow(2, s - 1)
P = inpl()
print(sum([sum([bin(L[j] & i).count('1') % 2 == P[j] for j in range(M)]) == M for i in range(pow(2, N))]))


(N, M) = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(M)]
(*p,) = map(int, input().split())
t = 0
a = 0
for i in range(2 ** N):
	t = 0
	for j in range(M):
		if sum((1 for h in k[j][1:] if i >> h - 1 & 1)) % 2 == p[j]:
			t += 1
	if t == M:
		a += 1
print(a)


import itertools
(N, M) = map(int, input().split())
k = []
for _ in range(M):
	k.append(list(map(int, input().split()))[1:])
p = list(map(int, input().split()))
ans = 0
for (i, s) in enumerate(itertools.product([0, 1], repeat=N)):
	if all([sum([s[j - 1] for j in v]) % 2 == t for (v, t) in zip(k, p)]):
		ans += 1
print(ans)


(N, M) = map(int, input().split())
L = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	lit = [0] * M
	for (j, switches) in enumerate(L):
		cnt = 0
		for s in switches:
			if i >> s - 1 & 1:
				cnt += 1
		if cnt % 2 == P[j]:
			lit[j] = 1
	if all(lit):
		ans += 1
print(ans)


(N, M) = [int(s) for s in input().split()]
S = []
for _ in range(M):
	l = [int(s) for s in input().split()]
	S.append(l[1:])
P = [int(s) for s in input().split()]
result = 0
for i in range(2 ** N):
	if all((sum(['{:0{N}b}'.format(i, N=N)[t - 1] == '1' for t in s]) % 2 == P[j] for (j, s) in enumerate(S))):
		result += 1
print(result)


(N, M) = map(int, input().split())
switch = []
for _ in range(M):
	tmp = list(map(int, input().split()))
	switch.append(tmp[1:])
p = list(map(int, input().split()))
from itertools import product
candidate = list(product([0, 1], repeat=N))
ans = 0
for cand in candidate:
	flag = True
	for (idx, snum) in enumerate(switch):
		tmp = 0
		for s in snum:
			tmp += cand[s - 1]
		if p[idx] != tmp % 2:
			flag = False
			break
	if flag:
		ans += 1
print(ans)


def LI():
	return list(map(int, input().split()))
(N, M) = LI()
ks = [LI() for _ in range(M)]
p = LI()
ans = 0
for i in range(2 ** N):
	bit = [i >> j & 1 for j in range(N)]
	for (j, x) in enumerate(ks):
		if p[j] != sum([bit[y - 1] for y in x[1:]]) % 2:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
s = [[]] * m
for i in range(m):
	s[i] = list(map(int, input().split()))
	del s[i][0]
p = list(map(int, input().split()))
ans = 0
for bit in range(1 << n):
	x = 0
	for i in range(m):
		y = 0
		for j in s[i]:
			if bit & 1 << j - 1:
				y += 1
		if y % 2 == p[i] % 2:
			x += 1
	if x == m:
		ans += 1
print(ans)


I = lambda : map(int, input().split())
(N, M) = I()
sw = []
for _ in [0] * M:
	(_, *s) = I()
	sw += [s]
(*p,) = I()
r = 0
for i in range(2 ** N):
	k = str(bin(i))[2:].rjust(N, '0')
	f = True
	for j in range(M):
		t = 0
		for s in sw[j]:
			if k[s - 1] == '1':
				t += 1
		if t % 2 != p[j]:
			f = False
			break
	if f:
		r += 1
print(r)


(n, m) = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
c = 0
for _ in range(2 ** n):
	s = format(_, '0{}b'.format(n))
	f = 1
	for i in range(m):
		a = 0
		for j in range(1, k[i][0] + 1):
			a += int(s[k[i][j] - 1])
		if a % 2 != p[i]:
			f = 0
			break
	if f:
		c += 1
print(c)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for bit in range(2 ** n):
	ok = True
	for j in range(m):
		c = 0
		k = s[j][0]
		for l in range(1, k + 1):
			if bit & 1 << s[j][l] - 1:
				c += 1
		if c % 2 != p[j]:
			ok = False
	if ok:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
ks = [list(map(int, input().split())) for _ in [0] * M]
(*p,) = map(int, input().split())
ans = 0
for i in range(1 << N):
	S = [i & 1 << j > 0 for j in range(N)]
	tmp = 0
	for (j, ks1) in enumerate(ks):
		(k, *s) = ks1
		tmp = sum((S[c - 1] for c in s))
		if tmp % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
bulbbit = [0] * m
for i in range(m):
	tmp = list(map(int, input().split()))
	for j in range(1, tmp[0] + 1):
		bulbbit[i] |= 1 << tmp[j] - 1
p = list(map(int, input().split()))
ans = 0
for s in range(1 << n):
	cnt = 0
	for i in range(m):
		swon = 0
		for j in range(n):
			if s >> j & 1 and bulbbit[i] >> j & 1:
				swon += 1
		if swon % 2 == p[i]:
			cnt += 1
	if cnt == m:
		ans += 1
print(ans)


from itertools import product
(n, m) = map(int, input().split())
switch = []
for i in range(m):
	(k, *s) = map(int, input().split())
	s = list(s)
	switch.append(s)
p = list(map(int, input().split()))
ans = 0
for i in product(range(2), repeat=n):
	flag = True
	for s in range(m):
		cnt = 0
		for t in switch[s]:
			if i[t - 1] == 1:
				cnt += 1
		if cnt % 2 != p[s]:
			flag = False
			break
	if flag == True:
		ans += 1
print(ans)


(N, M) = list(map(int, input().split()))
s_lst = [[False] * N for _ in range(M)]
for i in range(M):
	ks = list(map(int, input().split()))
	for (j, value) in enumerate(ks):
		if j != 0:
			s_lst[i][value - 1] = True
p = list(map(int, input().split()))
ans = 0
for bit in range(2 ** N):
	cnt = [0] * M
	for i in range(N):
		if bit >> i & 1 == 1:
			for j in range(M):
				if s_lst[j][i]:
					cnt[j] += 1
	flug = True
	for i in range(M):
		if cnt[i] % 2 != p[i]:
			flug = False
	if flug:
		ans += 1
print(ans)


(n, m) = list(map(int, input().split()))
light = [list(map(int, input().split())) for _ in range(m)]
lighton = list(map(int, input().split()))
swicth = []
for i in range(2 ** n):
	a = [0] * n
	for j in range(n):
		if i >> j & 1:
			a[j] = 1
	swicth.append(a)
ans = 0
for x in swicth:
	for y in range(m):
		b = light[y][1:]
		total = 0
		for z in b:
			total += x[z - 1]
		if total % 2 != lighton[y]:
			break
	else:
		ans += 1
print(ans)


def light(l, i):
	k = 1 << i - 1
	if l & k:
		return 1
	else:
		return 0
(N, M) = map(int, input().split())
s = list()
for j in range(0, M):
	s.append(0)
for j in range(0, M):
	s[j] = list(map(int, input().split()))
p = list(map(int, input().split()))
a = 0
for l in range(0, 1 << N):
	b = 0
	for j in range(0, M):
		c = 0
		for i in range(1, s[j][0] + 1):
			c += light(l, s[j][i])
		if c % 2 == p[j]:
			b += 1
	if b == M:
		a += 1
print(a)


import itertools
(N, M) = list(map(int, input().split()))
A = []
for m in range(M):
	a = list(map(int, input().split()))
	A.append(a[1:])
P = list(map(int, input().split()))
S = itertools.product([0, 1], repeat=N)
ans = 0
for s in S:
	flag = True
	for i in range(M):
		temp = 0
		for a in A[i]:
			temp += s[a - 1]
		if temp % 2 != P[i]:
			flag = False
	if flag == True:
		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()))
cnt = 0
for i in range(2 ** N):
	flag = True
	for j in range(M):
		if not [i >> k - 1 & 1 for k in s[j]].count(1) % 2 == p[j]:
			flag = False
	if flag:
		cnt += 1
print(cnt)


(N, M) = map(int, input().split())
K = [set(list(map(int, input().split()))[1:]) for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	S = set([1 + j for j in range(N) if 2 ** j & i])
	for (j, k) in enumerate(K):
		if len(S.intersection(k)) % 2 != P[j]:
			break
	else:
		ans += 1
print(ans)


from itertools import product
(n, m) = map(int, input().split())
l = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
c = 0
for sw in product((0, 1), repeat=n):
	for i in range(m):
		if sum((sw[si - 1] for si in l[i][1:])) % 2 != p[i]:
			break
	else:
		c += 1
print(c)


from itertools import product
(N, M) = map(int, input().split())
S = []
for _ in range(M):
	(_, *s) = map(int, input().split())
	S.append(s)
P = [int(s) for s in input().split()]
cnt = 0
for ss in product([0, 1], repeat=N):
	for i in range(M):
		if sum((ss[sj - 1] for sj in S[i])) % 2 != P[i]:
			break
	else:
		cnt += 1
print(cnt)


(N, M) = map(int, input().split())
s = [list(map(lambda x: int(x) - 1, input().split()[1:])) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	bulb_num = 0
	for j in range(M):
		on_num = 0
		for k in range(N):
			if i >> k & 1 and k in s[j]:
				on_num += 1
		if (on_num - p[j]) % 2 == 0:
			bulb_num += 1
	if bulb_num == M:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
a = [bin(j)[2:].zfill(n) for j in range(2 ** n)]
ans = 0
for jj in range(2 ** n):
	b = 0
	for i in range(m):
		num = 0
		for ii in range(1, s[i][0] + 1):
			num += int(a[jj][s[i][ii] - 1])
		if num % 2 != p[i]:
			b += 1
	if b == 0:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
lights = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
	onoff = bin(i)[2:].zfill(N)
	for (j, switches) in enumerate(lights):
		if sum((onoff[s - 1] == '1' for s in switches[1:])) % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


(n, m) = list(map(int, input().split()))
K = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	bit = [i >> j & 1 for j in range(n)]
	for (j, k) in enumerate(K):
		if p[j] != sum([bit[l - 1] for l in k]) % 2:
			break
	else:
		ans += 1
print(ans)


from itertools import combinations
(n, m) = map(int, input().split())
ksm = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
onoff = [0] * n
total = 0

def dfs(i, onoff):
	nonlocal total
	if i == n:
		flag = True
		for (idx, j) in enumerate(ksm):
			count = 0
			for k in j[1:]:
				count += onoff[k - 1]
			if count % 2 != p[idx]:
				flag = False
		if flag:
			total += 1
		return
	dfs(i + 1, onoff[:])
	dfs(i + 1, onoff[:i] + [1] + onoff[i + 1:])
dfs(0, onoff)
print(total)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
t = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	bit = [i >> j & 1 for j in range(n)]
	for (k, x) in enumerate(s):
		if t[k] != sum([bit[y - 1] for y in x[1:]]) % 2:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	tmp = 0
	f = 1
	for mm in range(m):
		tmp = 0
		for j in info[mm][1:]:
			tmp += int(str(format(i, 'b').zfill(n))[int(j) - 1])
		if tmp % 2 != p[mm]:
			f = 0
	if f == 1:
		ans += 1
print(ans)


(n, m) = list(map(int, input().split()))
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	sw = []
	on = 0
	for j in range(n):
		sw.append(i >> j & 1)
	for k in range(m):
		if sum([sw[ks[k][j + 1] - 1] for j in range(ks[k][0])]) % 2 == p[k]:
			on += 1
	if on == m:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
(k, s) = ([], [])
for i in range(m):
	inp = list(map(int, input().split()))
	(k_, s_) = (inp[0], inp[1:])
	k.append(k_)
	s.append(s_)
p = list(map(int, input().split()))
ans = 0
for bit in range(1 << n):
	flg = True
	for i in range(m):
		cnt = 0
		for e in s[i]:
			e -= 1
			if bit & 1 << e:
				cnt += 1
		if cnt % 2 != p[i]:
			flg = False
	if flg:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
s = [0] * n
for i in range(m):
	k = list(map(int, input().split()))
	for j in range(1, k[0] + 1):
		s[k[j] - 1] |= 1 << i
p = 0
k = list(map(int, input().split()))
for i in range(m):
	p |= k[i] << i
ans = 0
for i in range(1 << n):
	t = 0
	for j in range(n):
		if i >> j & 1:
			t ^= s[j]
	if t == p:
		ans += 1
print(ans)


N = None
M = None
S = []
P = []

def __starting_point():
	(N, M) = map(int, input().split())
	for _ in range(M):
		row = list(map(int, input().split()))[1:]
		S.append(row)
	P = list(map(int, input().split()))
	ans = 0
	for bit in range(1 << N):
		on_switches = []
		light = 0
		for i in range(N):
			if bit >> i & 1:
				on_switches.append(i)
		for i in range(M):
			cnt = 0
			for s in S[i]:
				for on_switch in on_switches:
					if s == on_switch + 1:
						cnt += 1
			if cnt % 2 == P[i]:
				light += 1
		if light == M:
			ans += 1
	print(ans)
__starting_point()


(N, M) = list(map(int, input().split()))
S = [0] * M
answer = 0
for i in range(M):
	S[i] = list(map(int, input().split()))
P = list(map(int, input().split()))
for i in range(2 ** N):
	mb = '0' + str(N) + 'b'
	bi = format(i, mb)
	count = 0
	for j in range(M):
		on = 0
		for k in range(S[j][0]):
			on += int(bi[-S[j][k + 1]])
		if on % 2 == P[j]:
			count += 1
	if count == M:
		answer += 1
print(answer)


from itertools import product
(n, m) = map(int, input().split())
switches = []
for _ in range(m):
	x = list(map(int, input().split()))[1:]
	temp = []
	for i in range(n):
		if i + 1 in x:
			temp.append(1)
		else:
			temp.append(0)
	switches.append(temp)
p = list(map(int, input().split()))
ans = 0
for on_off in product([1, 0], repeat=n):
	flag = 1
	for (i, switch) in enumerate(switches):
		cnt = 0
		for (x, y) in zip(on_off, switch):
			if x == 1 and y == 1:
				cnt += 1
		if cnt % 2 != p[i]:
			flag = 0
	if flag:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
li = []
for i in range(m):
	a = list(map(int, input().split()))
	li.append(a[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	ok = 1
	s = []
	for j in range(n):
		if i >> j & 1:
			s.append(j)
	for j in range(m):
		tmp = 0
		for k in li[j]:
			if k - 1 in s:
				tmp += 1
		if tmp % 2 != p[j]:
			ok = 0
	if ok:
		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)


def f(i):
	if i == n:
		on = [0] * m
		for j in range(m):
			for k in range(1, s[j][0] + 1):
				if t[s[j][k] - 1]:
					on[j] += 1
		for j in range(m):
			if not on[j] % 2 == p[j]:
				return
		nonlocal ans
		ans += 1
		return
	t[i] = 1
	f(i + 1)
	t[i] = 0
	f(i + 1)
	return
(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
t = [0] * n
f(0)
print(ans)


(n, m) = map(int, input().split())
ks = []
ss = []
for _ in range(m):
	row = list(map(lambda x: int(x) - 1, input().split()))
	ks.append(row[0] + 1)
	ss.append(row[1:])
ps = list(map(int, input().split()))

def is_bulb_on(bits, i):
	cnt = 0
	for s in ss[i]:
		if bits[s]:
			cnt += 1
	return cnt % 2 == ps[i]

def are_all_bulb_on(bits):
	good = True
	i = 0
	while good and i < m:
		good &= is_bulb_on(bits, i)
		i += 1
	return good

def rec(bits, i):
	if i == n:
		return 1 if are_all_bulb_on(bits) else 0
	cnt = 0
	cnt += rec(bits, i + 1)
	bits[i] = 1
	cnt += rec(bits, i + 1)
	bits[i] = 0
	return cnt
bits = [0] * n
print(rec(bits, 0))


from itertools import product
(n, m) = list(map(int, input().split()))
S = []
for _ in range(m):
	(k, *s) = list(map(int, input().split()))
	S.append(s)
p = list(map(int, input().split()))
ans = 0
for pattern in product(range(2), repeat=n):
	for (x, y) in zip(S, p):
		on_cnt = sum([pattern[s - 1] == 1 for s in x])
		if on_cnt % 2 != y:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
res1 = 0
for i in range(2 ** n):
	res2 = 0
	for j in range(m):
		cnt = 0
		for s in range(ks[j][0]):
			if i >> ks[j][s + 1] - 1 & 1:
				cnt += 1
		if cnt % 2 == p[j]:
			res2 += 1
	if res2 == m:
		res1 += 1
print(res1)


(n, m) = map(int, input().split())
S = []
for _ in range(m):
	s = list(map(int, input().split()))
	S.append(s[1:])
P = tuple(map(int, input().split()))
ans = 0
for i in range(1 << n):
	for j in range(m):
		cnt = 0
		for k in S[j]:
			if i & 1 << k - 1:
				cnt += 1
		if cnt % 2 != P[j]:
			break
	else:
		ans += 1
print(ans)


(n, m) = list(map(int, input().split()))
cs = [list(map(int, input().split())) for _ in range(m)]
ps = list(map(int, input().split()))
ans = 0
for on in range(2 ** n):
	patern = bin(on)[2:].rjust(n, '0')
	ok = True
	for i in range(m):
		ct = 0
		for j in range(cs[i][0]):
			if patern[cs[i][j + 1] - 1] == '1':
				ct += 1
		if ct % 2 != ps[i]:
			ok = False
	if ok:
		ans += 1
print(ans)


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


import sys
input = sys.stdin.readline

def I():
	return int(input())

def MI():
	return list(map(int, input().split()))

def LI():
	return list(map(int, input().split()))
(n, m) = MI()
sws = []
for i in range(m):
	sws.append(list(map(int, input().split())))
ps = LI()
ans = 0
for i in range(2 ** n):
	count = 0
	for j in range(m):
		sm = 0
		for k in range(1, len(sws[j])):
			sm += (i >> sws[j][k] - 1) % 2
		if sm % 2 == ps[j]:
			count += 1
	if count == m:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
km = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	flag = True
	for j in range(m):
		c = 0
		for k in km[j][1:]:
			if i & 2 ** (k - 1):
				c += 1
		if c % 2 != p[j]:
			flag = False
	if flag:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	flag = True
	for j in range(m):
		on = 0
		a = False
		for l in ks[j]:
			if a and i >> l - 1 & 1:
				on += 1
			a = True
		if on % 2 != p[j]:
			flag = False
			break
	if flag:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
s = []
for _ in range(m):
	(_, *t) = map(int, input().split())
	s.append(t)
(*p,) = map(int, input().split())
print(sum([all([sum([i >> u - 1 for u in s[j]]) % 2 == p[j] for j in range(m)]) for i in range(2 ** n)]))


(n, m) = map(int, input().split())
s = []
for _ in range(m):
	ks = list(map(int, input().split()))
	s.append(ks[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	for (x, y) in zip(s, p):
		flag = False
		for a in x:
			if i & 1 << a - 1:
				flag = not flag
		if int(flag) != y:
			break
	else:
		ans += 1
print(ans)


import itertools
(n, m) = map(int, input().split())
L = []
for i in range(m):
	(a, *l) = map(int, input().split())
	L += [l]
S = list(map(int, input().split()))
ans = 0
for i in itertools.product([0, 1], repeat=n):
	f = 0
	for (l, s) in zip(L, S):
		ls = 0
		for ll in l:
			ls += i[ll - 1]
		if ls % 2 == s:
			f += 1
	if f == m:
		ans += 1
print(ans)


(n, m) = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	good = True
	for j in range(m):
		cur = 0
		for e in s[j][1:]:
			if i & 1 << e - 1:
				cur += 1
		if cur % 2 != p[j]:
			good = False
			break
	if good:
		ans += 1
print(ans)


(n, m) = [int(i) for i in input().split()]
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
cnt = 0
for i in range(2 ** n):
	on = set((j + 1 for j in range(n) if i >> j & 1 == 1))
	flag = True
	for j in range(m):
		(_, *s) = ks[j]
		flag &= len(on & set(s)) % 2 == p[j]
	cnt += flag
print(cnt)


(n, m) = map(int, input().split())
ks = [[] for i in range(m)]
for i in range(m):
	ks[i] = list(map(lambda x: int(x) - 1, input().split()))
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	l = [0] * n
	for j in range(n):
		l[j] = 1 if i >> j & 1 else 0
	for j in range(m):
		s = sum([l[k] for k in ks[j][1:]])
		if s % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
sw = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	f = 1
	for j in range(m):
		c = 0
		for x in sw[j][1:]:
			x -= 1
			c += i >> x & 1
		if c % 2 != p[j]:
			f = 0
	ans += 1 if f else 0
print(ans)


(N, M) = map(int, input().split())
S = []
for m in range(M):
	nums = list(map(int, input().split()))
	S.append(nums[1:])
p = list(map(int, input().split()))
ans = 0
for bits in range(1 << N):
	for m in range(M):
		on = 0
		for s in S[m]:
			on += bits >> s - 1 & 1
		if on & 1 != p[m]:
			break
	else:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
l = []
for i in range(M):
	l.append(list(map(int, input().split()))[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	isOK = True
	for j in range(M):
		stat = 0
		for k in l[j]:
			k -= 1
			if i & 1 << k:
				stat = (stat + 1) % 2
		if stat != p[j]:
			isOK = False
	if isOK:
		ans += 1
print(ans)


import itertools
(N, M) = [int(_) for _ in input().split()]
KS = [[int(_) - 1 for _ in input().split()] for _ in range(M)]
P = [int(_) for _ in input().split()]
ans = 0
for switches in itertools.product(range(2), repeat=N):
	f = all((sum((switches[s] for s in ks[1:])) % 2 == P[i] for (i, ks) in enumerate(KS)))
	ans += f
print(ans)


(N, M) = map(int, input().split())
L = []
for _ in range(M):
	(k, *S) = map(int, input().split())
	L.append(S)
P = list(map(int, input().split()))
c = 0
for i in range(2 ** N):
	A = []
	for j in range(N):
		if i >> j & 1:
			A.append(j + 1)
	A = set(A)
	for i in range(M):
		if len(A & set(L[i])) % 2 != P[i]:
			break
	else:
		c += 1
print(c)


(n, m) = map(int, input().split())
swithes = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
total = 0
for i in range(2 ** n):
	bag = []
	ans = 0
	for j in range(n):
		if i >> j & 1:
			bag.append(j + 1)
	for k in range(m):
		a = 0
		for l in range(swithes[k][0]):
			if swithes[k][l + 1] in bag:
				a += 1
		if a % 2 == p[k]:
			ans += 1
	if ans == m:
		total += 1
print(total)


(n, m) = map(int, input().split())
X = []
for _ in range(m):
	(k, *A) = list(map(int, input().split()))
	b = 0
	for a in A:
		b += 1 << a - 1
	X.append(b)
P = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	for (x, p) in zip(X, P):
		y = i & x
		c = bin(y).count('1') % 2
		if c != p:
			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()))
c = 0
from itertools import product
for i in product([0, 1], repeat=n):
	if all((len([None for t in t if i[t - 1]]) % 2 == p[j] for (j, t) in enumerate(s))):
		c += 1
print(c)


(n, m) = map(int, input().split())
S = [list(map(int, input().split()))[1:] for i in range(m)]
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	for (s, p) in zip(S, P):
		c = 0
		for t in s:
			if i >> t - 1 & 1:
				c += 1
		if c % 2 != p:
			break
	else:
		ans += 1
print(ans)


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


(N, M) = map(int, input().split())
lamps = [list(map(lambda x: int(x) - 1, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
	for lamp in range(M):
		on_sum = 0
		for j in range(N):
			if i >> j & 1 and j in lamps[lamp]:
				on_sum += 1
		if on_sum % 2 != p[lamp]:
			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()))
ans = 0
for i in range(2 ** n):
	f = 1
	for j in range(m):
		g = 1
		g &= sum([int(bin(i >> u - 1), 2) for u in s[j]]) % 2 == p[j]
		f &= g
	ans += f
print(ans)


import itertools
(n, m) = list(map(int, input().split()))
L = [list(map(int, input().split()))[1:] for i in range(m)]
P = list(map(int, input().split()))
cnt = 0
for i in range(1 << n):
	k = 1
	for (p, ll) in zip(P, L):
		k *= sum([int(bin(i)[2:].zfill(n)[l - 1]) for l in ll]) % 2 == p
	cnt += k
print(cnt)


(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 p[m] != [bin(bit)[2:].zfill(N)[s - 1] for s in S[m]].count('1') % 2:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	val = []
	tmp = i
	for j in range(n):
		val.append(tmp % 2)
		tmp //= 2
	if all((sum((val[k - 1] for k in ks[j][1:])) % 2 == p[j] for j in range(m))):
		ans += 1
print(ans)


(n, m) = map(int, input().split())
li = []
for i in range(m):
	(dk, *d) = list(map(int, input().split()))
	li.append(d)
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	sw = bin(i)[2:].zfill(n)
	for j in range(m):
		cnt = 0
		for k in li[j]:
			if sw[k - 1] == '1':
				cnt += 1
		if cnt % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


(N, M) = (int(_) for _ in input().split())
A = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
	for (j, S) in enumerate(A):
		if P[j] ^ sum((i >> k - 1 & 1 for k in S)) & 1:
			break
	else:
		ans += 1
print(ans)


(N, M) = list(map(int, input().split()))
s = [sum([2 ** (i - 1) for i in list(map(int, input().split()))[1:]]) for _ in range(M)]
p = list(map(int, input().split()))
(ans, n) = (0, 2 ** N)
for i in range(n):
	for (s_, p_) in zip(s, p):
		if bin(i & s_).count('1') % 2 != p_:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	judge = True
	switch = ['off' for _ in range(n)]
	for j in range(len(switch)):
		if i >> j & 1:
			switch[j] = 'on'
	for k in range(m):
		count = 0
		for l in range(ks[k][0]):
			if switch[ks[k][l + 1] - 1] == 'on':
				count += 1
		if count % 2 != p[k]:
			judge = False
			break
	if judge == True:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
flgs = [0] * M
for i in range(M):
	(k, *vals) = map(int, input().split())
	for v in vals:
		flgs[i] |= 1 << v - 1
p = list(map(int, input().split()))
cnt = 0
for bit in range(2 ** N):
	cnt_tmp = 1
	for (i, f) in enumerate(flgs):
		if len([j for j in range(N) if f & bit & 1 << j != 0]) % 2 != p[i]:
			cnt_tmp = 0
	cnt += cnt_tmp
print(cnt)


(n, m) = map(int, input().split())
A = []
for _ in range(m):
	(k, *s) = map(int, input().split())
	c = 0
	for i in s:
		c += 2 ** (i - 1)
	A.append(c)
P = tuple(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	f = True
	for j in range(m):
		c = bin(i & A[j]).count('1')
		if c % 2 != P[j]:
			f = False
			break
	if f:
		ans += 1
print(ans)


from itertools import product
(n, m) = map(int, input().split())
s = []
for _ in range(m):
	(_, *t) = map(int, input().split())
	s.append(t)
p = [int(i) for i in input().split()]
cnt = 0
for fl in product([0, 1], repeat=n):
	for i in range(m):
		if sum((fl[tmp - 1] for tmp in s[i])) % 2 != p[i]:
			break
	else:
		cnt += 1
print(cnt)


(n, m) = map(int, input().split())
bulbs = []
ans = 0
for i in range(m):
	c = tuple(map(int, input().split()))
	bulbs.append(c[1:])
p = list(map(int, input().split()))
for i in range(2 ** n):
	cnt = 0
	for (j, bulbs_sub) in enumerate(bulbs):
		switch_on = 0
		for l in bulbs_sub:
			if i >> l - 1 & 1:
				switch_on += 1
		if switch_on % 2 == p[j]:
			cnt += 1
	if cnt == m:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
s = [list(map(int, input().split()))[1:] for i in range(M)]
p = list(map(int, input().split()))
cnt = 0
for a in range(2 ** N):
	flag = 1
	for i in range(M):
		if sum([a >> x - 1 & 1 for x in s[i]]) % 2 != p[i]:
			flag = 0
			break
	cnt += flag
print(cnt)


from itertools import product
(n, m) = map(int, input().split())
s = [list(map(lambda x: int(x) - 1, input().split()[1:])) for _ in range(m)]
p = list(map(int, input().split()))
print(sum((all((sum((b[ki] for ki in s[i])) % 2 == p[i] for i in range(m))) for b in product((True, False), repeat=n))))


(N, M) = map(int, input().split())
s = [list(map(int, input().split()))[1:] for i in range(M)]
p = list(map(int, input().split()))
(ans, cnt) = (0, 0)
for n in range(2 ** N):
	for m in range(M):
		cnt = 0
		for i in range(N):
			if n >> i & 1 and i + 1 in s[m]:
				cnt += 1
		if cnt % 2 != p[m]:
			break
	else:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	s = i
	b = [0] * N
	for j in range(N):
		if s >= 2 ** (N - j - 1):
			s -= 2 ** (N - j - 1)
			b[j] = 1
	for j in range(M):
		on = 0
		for k in range(ks[j][0]):
			if b[ks[j][k + 1] - 1] == 1:
				on += 1
		if on % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


from itertools import *
(N, M) = map(int, input().split())
K = [list(map(int, input().split()))[1:] for m in range(M)]
P = list(map(int, input().split()))
print(sum([all([sum([s[j - 1] for j in v]) % 2 == t for (v, t) in zip(K, P)]) for s in product([0, 1], repeat=N)]))


(n, m) = map(int, input().split())
swiches = []
for i in range(m):
	s = 0
	for j in list(map(int, input().split()))[1:]:
		s += 2 ** (j - 1)
	swiches.append(s)
pli = list(map(int, input().split()))
cnt = 0
for i in range(2 ** n):
	flag = True
	for (p, s) in zip(pli, swiches):
		if p != bin(i & s).count('1') % 2:
			flag = False
			break
	if flag:
		cnt += 1
print(cnt)


(n, m) = map(int, input().split())
s = []
for _ in range(m):
	(k, *b) = map(int, input().split())
	s.append(b)
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	tr = bin(i)[2:].zfill(n)
	light = 0
	for j in range(m):
		sw = 0
		for l in s[j]:
			if tr[l - 1] == '1':
				sw += 1
		if sw % 2 == p[j]:
			light += 1
	if light == m:
		ans += 1
print(ans)


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


(N, M) = map(int, input().split())
k = []
for i in range(M):
	temp = list(map(int, input().split()))
	k.append(temp[1:])
p = list(map(int, input().split()))
result = 0
for i in range(2 ** N):
	for (j, v) in enumerate(k):
		s = [1 for temp in v if 2 ** (temp - 1) & i]
		if sum(s) % 2 != p[j]:
			break
	else:
		result += 1
print(result)


import re
import sys
import math
import itertools
import bisect
import heapq
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def get_primenumber(number):
	prime_list = []
	search_list = list(range(2, number + 1))
	while search_list[0] <= math.sqrt(number):
		head_num = search_list.pop(0)
		prime_list.append(head_num)
		search_list = [num for num in search_list if num % head_num != 0]
	prime_list.extend(search_list)
	return prime_list

def factrization_prime(number):
	factor = {}
	div = 2
	s = math.sqrt(number)
	while div < s:
		div_cnt = 0
		while number % div == 0:
			div_cnt += 1
			number //= div
		if div_cnt != 0:
			factor[div] = div_cnt
		div += 1
	if number > 1:
		factor[number] = 1
	return factor

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

def I():
	return map(int, input().split())

def X():
	return list(input())

def L():
	return list(input().split())

def l():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 6)
mod = 10 ** 9 + 7
cnt = 0
ans = 0
num = []
inf = float('inf')
al = 'abcdefghijklmnopqrstuvwxyz'
AL = al.upper()
(n, m) = I()
switch = [l() for _ in range(m)]
p = l()
for bit in range(2 ** n):
	poi = [0] * n
	for i in range(n):
		if bit >> i & 1:
			poi[i] = 1
	for j in range(m):
		ans = 0
		for k in range(switch[j][0]):
			if poi[switch[j][k + 1] - 1] == 1:
				ans += 1
		if ans % 2 != p[j]:
			break
	else:
		cnt += 1
print(cnt)


import sys

def MI():
	return map(int, sys.stdin.readline().rstrip().split())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))
(n, m) = MI()
lights = [LI() for _ in range(m)]
p_list = LI()
bit_list = []
count = 0
for i in range(2 ** n):
	bit = [i >> j & 1 for j in range(n)]
	flag = 0
	for j in range(m):
		ki = lights[j][0]
		onswitch = 0
		for k in range(1, ki + 1):
			si = lights[j][k]
			onswitch += bit[si - 1]
		if onswitch % 2 != p_list[j]:
			flag += 1
	if flag == 0:
		count += 1
print(count)


(n, m) = map(int, input().split())
data = []
for i in range(m):
	(k, *s) = map(int, input().split())
	data.append(set(s))
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	on = set()
	for j in range(n):
		if i >> j & 1:
			on.add(j + 1)
	if all([len(on & data[l]) % 2 == p[l] for l in range(m)]):
		ans += 1
print(ans)


(N, M) = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
	judge = 1
	for j in range(M):
		cnt = 0
		for k in KS[j][1:]:
			if i >> k - 1 & 1:
				cnt += 1
		if cnt % 2 != p[j]:
			judge = 0
	if judge == 1:
		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()))
count = 0
for i in range(2 ** n):
	flag = True
	for j in range(m):
		if not [1 & i >> k - 1 for k in s[j]].count(1) % 2 == p[j]:
			flag = False
	if flag:
		count += 1
print(count)


(N, M) = map(int, input().split())
L = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	lit = [0] * M
	for (j, switch) in enumerate(L):
		cnt = 0
		for s in switch:
			if i >> s - 1 & 1:
				cnt += 1
		if cnt % 2 == P[j]:
			lit[j] = True
		else:
			lit[j] = False
	if all(lit):
		ans += 1
print(ans)


(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())
K = []
S = []
for i in range(M):
	k = 0
	s = []
	(k, *s) = map(int, input().split())
	K.append(k)
	S.append(s)
P = list(map(int, input().split()))
res = 0
for bit in range(1 << N):
	judge = True
	for i in range(M):
		cnt = 0
		for s in S[i]:
			cnt += bit >> s - 1 & 1
		if cnt % 2 != P[i]:
			judge = False
	if judge:
		res += 1
print(res)


(N, M) = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	bit = [i >> j & 1 for j in range(N)]
	for (k, x) in enumerate(ks):
		(_, *s) = x
		if p[k] != sum([bit[y - 1] for y in s]) % 2:
			break
	else:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
S = [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
			else:
				flag = 0
		if cnt % 2 == P[j]:
			sw[j] = True
	if all(sw):
		ans += 1
print(ans)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
ks = list((list(map(int, input().split())) for _ in range(m)))
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	c = [False] * n
	for j in range(n):
		if i >> j & 1:
			c[j] = True
	for j in range(m):
		(count, l) = (0, ks[j][0])
		for k in range(l):
			if c[ks[j][k + 1] - 1]:
				count += 1
		if count % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
l = [list(map(int, input().split()))[1:] for i in range(m)]
p = list(map(int, input().split()))
form = '0' + str(n) + 'b'
ans = 0
for i in range(2 ** n):
	ptr = format(i, form)
	flg = True
	for j in range(m):
		s = sum((int(ptr[k - 1]) for k in l[j]))
		if s % 2 != p[j]:
			flg = False
	if flg == True:
		ans += 1
print(ans)


def func(sw, p, bit):
	sum_on = 0
	for k in range(sw[0]):
		idx = sw[k + 1] - 1
		if bit[idx] == 1:
			sum_on += 1
	if sum_on % 2 == p:
		res = 1
	else:
		res = 0
	return res
(N, M) = list(map(int, input().split()))
SW = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
	bit = [0] * N
	for j in range(N):
		div = 1 << j
		bit[j] = i // div % 2
	cnt = 0
	for m in range(M):
		res = func(SW[m], P[m], bit)
		if res == 1:
			cnt += 1
	if cnt == M:
		ans += 1
print(ans)


from itertools import product
(n, m) = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
cnt = 0
for pat in product([0, 1], repeat=n):
	for i in range(m):
		if sum((pat[ks[i][j + 1] - 1] for j in range(ks[i][0]))) % 2 != p[i]:
			break
	else:
		cnt += 1
print(cnt)


(n, m) = map(int, input().split())
k = [[int(i) for i in input().split(' ')] for i in range(m)]
p = [int(i) for i in input().split(' ')]
c = 0
for i in range(2 ** n):
	t = bin(i + 2 ** n)[2:]
	a = sum([0 if sum([1 if t[l] == '1' else 0 for l in k[j][1:]]) % 2 == p[j] else 1 for j in range(len(k))])
	if a == 0:
		c += 1
print(c)


(n, m) = map(int, input().split(' '))
K = []
S = []
for i in range(m):
	l = list(map(int, input().split(' ')))
	K.append(l[0])
	S.append(l[1:])
p = list(map(int, input().split(' ')))
ans = 0
for i in range(2 ** n):
	light = 0
	for j in range(m):
		sw = 0
		for s in S[j]:
			if i >> s - 1 & 1:
				sw += 1
		if sw % 2 == p[j]:
			light += 1
	if light == m:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
k = [0] * m
s = []
for i in range(m):
	(k[i], *ss) = map(int, input().split())
	s.append(ss)
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	bi = bin(i)[2:].zfill(n)
	if all((sum((int(bi[sss - 1]) for sss in ss)) % 2 == p[j] for (j, ss) in enumerate(s))):
		ans += 1
print(ans)


import itertools
(n, m) = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for item in itertools.product([0, 1], repeat=n):
	for i in range(m):
		if sum([item[j - 1] for j in s[i]]) % 2 != p[i]:
			break
	else:
		ans += 1
print(ans)


(N, M) = list(map(int, input().split()))
Switch = [list([int(a) - 1 for a in input().split()])[1:] for i in range(M)]
P = list(map(int, input().split()))
from itertools import product
Target = product([0, 1], repeat=N)
ans = 0
for T in Target:
	akari = []
	for (i, S) in enumerate(Switch):
		temp = 0
		for s in S:
			a = T[s]
			if a == 1:
				temp += 1
		akari.append(temp)
	isOK = True
	for (j, ak) in enumerate(akari):
		if ak % 2 != P[j]:
			isOK = False
	if isOK:
		ans += 1
print(ans)


def resolve():
	(n, m) = map(int, input().split())
	s = list((list(map(int, input().split()))[1:] for _ in range(m)))
	p = list(map(int, input().split()))
	print(sum([1 for i in range(1 << n) if all([sum([1 for sji in sj if i & 1 << sji - 1]) % 2 == pj for (sj, pj) in zip(s, p)])]))
resolve()


import itertools
(N, M) = map(int, input().split())
k = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
print(sum([all([sum([s[j - 1] for j in v]) % 2 == t for (v, t) in zip(k, p)]) for s in itertools.product([0, 1], repeat=N)]))


(n, m) = map(int, input().split())
S = [list(map(int, input().split()))[1:] for i in range(m)]
P = list(map(int, input().split()))
cnt = 0
for i in range(2 ** n):
	pattern = format(i, 'b').zfill(n)
	point = 0
	for j in range(m):
		swi = 0
		for k in S[j]:
			if pattern[k - 1] == '1':
				swi += 1
		if swi % 2 == P[j]:
			point += 1
	if point == m:
		cnt += 1
print(cnt)


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


def abc128c_switches():
	import itertools
	(n, m) = map(int, input().split())
	s = []
	for _ in range(m):
		v = list(map(int, input().split()))
		v = v[1:]
		s.append(v)
	p = list(map(int, input().split()))
	pattern = itertools.product([0, 1], repeat=n)
	result = 0
	for pat in pattern:
		cnt = 0
		for i in range(m):
			total = 0
			for j in s[i]:
				if pat[j - 1] == 1:
					total += 1
			if total % 2 == p[i]:
				cnt += 1
		if cnt == m:
			result += 1
	print(result)
abc128c_switches()


(n, m) = map(int, input().split())
s = [[x for x in map(int, input().split())] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
	c = 1
	for j in range(m):
		t = 0
		for k in range(1, s[j][0] + 1):
			if i >> s[j][k] - 1 & 1 == 1:
				t += 1
		if t % 2 != p[j]:
			c = 0
			break
	if c:
		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()))
ret = 0
for b in range(1 << n):
	if all((sum((b >> i - 1 & 1 for i in s[j])) % 2 == p[j] for j in range(m))):
		ret += 1
print(ret)


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


(n, m) = map(int, input().split())
s = [0] * m
for i in range(m):
	s[i] = list(map(int, input().split()))
	del s[i][0]
p = list(map(int, input().split()))
count = 0
for i in range(2 ** n):
	for k in range(m):
		temp = 0
		for j in range(n):
			if i >> j & 1 and j + 1 in s[k]:
				temp = temp + 1
		if temp % 2 != p[k]:
			break
	else:
		count = count + 1
print(count)


(n, m) = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
k2 = []
for v in k:
	a = [2 ** (v[i] - 1) for i in range(1, v[0] + 1)]
	k2.append(sum(a))
p = list(map(int, input().split()))
sm = 0
for i in range(2 ** n):
	c = 1
	for j in range(m):
		b = bin(k2[j] & i)
		d = b.count('1')
		if d % 2 != p[j]:
			c = 0
	if c == 1:
		sm += 1
print(sm)


(n, m) = map(int, input().split())
ans = 0
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
for i in range(1 << n):
	for j in range(m):
		c = 0
		for ss in s[j][1:]:
			if i & 1 << ss - 1:
				c += 1
		if c % 2 != p[j]:
			break
	else:
		ans += 1
print(ans)


3
(N, M) = (int(x) for x in input().split())
S = []
for i in range(M):
	items = [int(x) - 1 for x in input().split()]
	S.append(items[1:])
P = [int(x) for x in input().split()]
ret = 0
for bit in range(2 ** N):
	on = [i for i in range(N) if bit & 1 << i]
	ok = True
	for i in range(M):
		s = S[i]
		p = P[i]
		if sum((1 for switch in s if switch in on)) % 2 != p:
			ok = False
			break
	if ok:
		ret += 1
print(ret)


(N, M) = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
	tmp = 1
	for (j, b) in enumerate(KS):
		if sum([1 for bb in b[1:] if i >> bb - 1 & 1 == 1]) % 2 != P[j]:
			tmp = 0
			break
	if tmp:
		ans += 1
print(ans)


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

def get_connected_switches():
	lst = list(map(int, input().split()))
	lst.pop(0)
	return list([1 << d - 1 for d in lst])
cs = [get_connected_switches() for _ in range(m)]
ps = list(map(int, input().split()))
ans = 0
for on in range(2 ** n):
	ok = True
	for i in range(m):
		ct = 0
		for s in cs[i]:
			if s & on:
				ct += 1
		if ct % 2 != ps[i]:
			ok = False
	if ok:
		ans += 1
print(ans)


from itertools import product
(n, m) = map(int, input().split())
sp = [list(map(int, input().split())) for _ in range(m + 1)]
print(sum((all((sum((i[a - 1] for a in s[1:])) % 2 == p for (s, p) in zip(sp[:m], sp[-1]))) for i in product((0, 1), repeat=n))))