import sys
from math import factorial
stdin = sys.stdin

ni = lambda: int(ns()) #int
na = lambda: list(map(int, stdin.readline().split())) #int,list
ns = lambda: stdin.readline().rstrip()  # str
n,m = na()
l=[]
for i in range(m):
	l.append(na()[1:])
p = na()
cnt=0
for i in range(m):
	if p[i]==1:
		s=len(l[i])
		while s>0:
			cnt+=factorial(len(l[i])) / factorial(s) / factorial(len(l[i])-s)
			s-=2
res = [ flatten for inner in l for flatten in inner ]
print(int(2**((n-len(set(res))))*cnt))