from sys import stdin
import itertools
N,M=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
P=[int(x) for x in stdin.readline().rstrip().split()]
ans=0
for n in list(itertools.product([0,1],repeat=N)):
    for ind,j in enumerate(data):
        flag = True
        fired=0
        for k in j[1:]:
            if n[k-1] == 1:
                fired+=1
            if int(fired%2) != P[ind]:
                flag = False
        if flag:
            ans+=1
print(ans)