N, M = map(int, input().split())
S = [0]*M
for i in range(M):
    s = list(map(int, input().split()))
    for j in s[1:]:
        S[i] += 2**(j-1)
p = list(map(int, input().split()))
ans = 0
for b in range(2**N):
    tmp = True
    for i, s in enumerate(S):
        tmp &= bin(b&s).count('1')%2==p[i]
    if tmp:
        ans += 1
print(ans)