N,M = map(int,input().split())
S = [tuple(map(int,input().split()[1:])) for i in range(M)]
P = list(map(int,input().split()))

ans = 0
for b in range(1<<N):
    for i,s in enumerate(S):
        c = 0
        for t in s:
            if b&(1<<(t-1)): c+=1
        if c%2!=P[i]: break
    else:
        ans += 1
print(ans)