n,m = map(int,input().split())
data = []
for i in range(m):
    k,*s = map(int,input().split())
    data.append(set(s))
p = list(map(int,input().split()))

ans = 0
for i in range(1<<n):
    on = set()
    for j in range(n):
        if i>>j&1:on.add(j+1)
    if all([len(on&data[l])%2==p[l] for l in range(m)]):ans+=1
print(ans)
