import numpy as np
from itertools import product

N, M = map(int, input().split())
S = np.zeros((M, N))  # (M, N), switch

for i in range(M):
    k, *s = map(int, input().split())
    s = [x - 1 for x in s]
    S[i, s] = 1
p = np.array(list(map(int, input().split())), dtype=np.int)

cnt = 0
for i in product([0, 1], repeat=N):
    a = np.array(i, dtype=np.int)  # N,
    b = (np.dot(S, a) % 2).astype(np.int)
    if np.all(b == p):
        cnt += 1
print(cnt)