import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, M = rl()
K = []
for i in range(M):
	ks = rl()
	K.append(ks[1:])
P = rl()

def check(b):
	for i in range(M):
		if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	return True

cnt = 0
for b in product([0, 1], repeat=N):
	if check(b):
		cnt += 1
print(cnt) import sys, math sys math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline rs = lambda: input().strip() rs lambda: input().strip() input().strip() ().strip () input strip ri = lambda: int(input()) ri lambda: int(input()) int(input()) int input() input rl = lambda: list(map(int, input().split())) rl lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split mod = 1000000007 mod 1000000007 sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 N, M = rl() N rl() rl M K = [] K [] for i in range(M):
	ks = rl()
	K.append(ks[1:]) i range(M) range M ks = rl() ks rl() rl K.append(ks[1:]) K.append K append ks[1:] ks 1: 1 P = rl() P rl() rl def check(b):
	for i in range(M):
		if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	return True check for i in range(M):
		if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	 i range(M) range M if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	 sum([b[k-1] for k in K[i]]) % 2 != P[i] sum([b[k-1] for k in K[i]]) % 2 sum([b[k-1] for k in K[i]]) sum [b[k-1] for k in K[i]] 2 P[i] P i return False False return True True b b cnt = 0 cnt 0 for b in product([0, 1], repeat=N):
	if check(b):
		cnt += 1 b product([0, 1], repeat=N) product [0, 1] 0 1 repeat=N repeat N if check(b):
		cnt += 1 check(b) check b cnt += 1 cnt 1 print(cnt) print cnt ks = rl() rl() ks P = rl() rl() P cnt += 1 1 cnt mod = 1000000007 1000000007 mod M = rl() rl() M cnt = 0 0 cnt input = sys.stdin.readline sys.stdin.readline input N, M = rl() rl() N K = [] [] K rl = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) rl ri = lambda: int(input()) lambda: int(input()) ri rs = lambda: input().strip() lambda: input().strip() rs def check(b):
	for i in range(M):
		if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	return True def check(b):
	for i in range(M):
		if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	return True check
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, M = rl()
K = []
for i in range(M):
	ks = rl()
	K.append(ks[1:])
P = rl()

def check(b):
	for i in range(M):
		if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	return True

cnt = 0
for b in product([0, 1], repeat=N):
	if check(b):
		cnt += 1
print(cnt)