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