import sys
import math
n,m=map(int,input().split())
k=[]
for i in range(m):
    s=list(map(int,input().split()))
    s = list(map( lambda x:x-1,s))
    k.append(s)
p=list(map(int,input().split()))

ans=0

for bit in range(1<<n):
    cnt_swit=[0]*m
    for i in range(n):
        if bit>>i & 1:
            for j in range(m):
                if i in k[j]:
                    cnt_swit[j]+=1
    cnt_swit = list(map( lambda x:x%2,cnt_swit))
    tmp=0
    for pi,cnt in zip(p,cnt_swit):
        if pi==cnt:
            tmp+=1
    if tmp==m:
        ans+=1
print(ans)


