n,m=map(int,input().split())
s=[]
for _ in range(m):
    _,*t=map(int,input().split())
    s.append(t)
p=list(map(int,input().split()))
a=0
for i in range(2**n):
    f=1
    for j in range(m):
        g=1
        g&=(sum([int(bin(i>>(u-1)),2) for u in s[j]])%2==p[j])
        f&=g
    a+=f
print(a)