n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    l=[False]*n
    for j in range(n):
        if(i>>j & 1):
            l[j]=True
    light=0
    for x,aa in enumerate(a):
        cnt=0
        for k in range(len(aa)):
            if k==0:
                continue
            if l[k-1]==True:
                cnt+=1
        if cnt%2==p[x]:
            light+=1
    if light==m:
        ans+=1
print(ans)