from itertools import product
import numpy as np

N, M = map(int,input().split())

lst = [list(map(int, input().split())) for _ in range(M)]
p_lst = np.array(list(map(int, input().split())))

ans = 0
mat = [[0]*N for _ in range(M)]

for j, lst2 in enumerate(lst):
    for i in lst2[1:]:
        mat[j-1][i-1] = 1

mat_np = np.array(mat)

for a in product([0, 1], repeat=N):
    l = np.array(a)
    b = np.dot(mat_np, l)%2
    if np.sum(b==p_lst)==M:ans += 1

print(ans)