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

s = [[] for _ in range(m)]

for i in range(m):
	k,*t = map(int,input().split())
	for j in t:
		s[i].append(j-1)

targ = list(map(int,input().split()))
ans = 0
#print(s)

for i in itertools.product(range(2), repeat=n):
	tmpl = [0]*m
	
	for j in range(m):
		for k in s[j]:
			tmpl[j] += i[k]
	
	mode = 1
	
	for j in range(m):
		if tmpl[j]%2 != targ[j]:
			mode = 0
			break
	
	if mode:
		ans += 1

print(ans) import itertools itertools n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [] s = [[] for _ in range(m)] s [[] for _ in range(m)] for i in range(m):
	k,*t = map(int,input().split())
	for j in t:
		s[i].append(j-1) i range(m) range m k,*t = map(int,input().split()) k map(int,input().split()) map int input().split() ().split () input split *t t for j in t:
		s[i].append(j-1) j t s[i].append(j-1) [i].append [i] s i append j-1 j 1 targ = list(map(int,input().split())) targ list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in itertools.product(range(2), repeat=n):
	tmpl = [0]*m
	
	for j in range(m):
		for k in s[j]:
			tmpl[j] += i[k]
	
	mode = 1
	
	for j in range(m):
		if tmpl[j]%2 != targ[j]:
			mode = 0
			break
	
	if mode:
		ans += 1 i itertools.product(range(2), repeat=n) itertools.product itertools product range(2) range 2 repeat=n repeat n tmpl = [0]*m tmpl [0]*m [0] 0 m for j in range(m):
		for k in s[j]:
			tmpl[j] += i[k]
	
	 j range(m) range m for k in s[j]:
			tmpl[j] += i[k]
	
	 k s[j] s j tmpl[j] += i[k] tmpl[j] tmpl j i[k] i k mode = 1 mode 1 for j in range(m):
		if tmpl[j]%2 != targ[j]:
			mode = 0
			break
	
	 j range(m) range m if tmpl[j]%2 != targ[j]:
			mode = 0
			break
	
	 tmpl[j]%2 != targ[j] tmpl[j]%2 tmpl[j] tmpl j 2 targ[j] targ j mode = 0 mode 0 break if mode:
		ans += 1 mode ans += 1 ans 1 print(ans) print ans s = [[] for _ in range(m)] [[] for _ in range(m)] s targ = list(map(int,input().split())) list(map(int,input().split())) targ mode = 1 1 mode ans += 1 1 ans m = map(int,input().split()) map(int,input().split()) m tmpl = [0]*m [0]*m tmpl mode = 0 0 mode n,m = map(int,input().split()) map(int,input().split()) n ans = 0 0 ans k,*t = map(int,input().split()) map(int,input().split()) k
import itertools
n,m = map(int,input().split())

s = [[] for _ in range(m)]

for i in range(m):
	k,*t = map(int,input().split())
	for j in t:
		s[i].append(j-1)

targ = list(map(int,input().split()))
ans = 0
#print(s)

for i in itertools.product(range(2), repeat=n):
	tmpl = [0]*m
	
	for j in range(m):
		for k in s[j]:
			tmpl[j] += i[k]
	
	mode = 1
	
	for j in range(m):
		if tmpl[j]%2 != targ[j]:
			mode = 0
			break
	
	if mode:
		ans += 1

print(ans)