import itertools

N, M = list(map(int, input().split()))
S = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
cnt = 0
for pattern in itertools.product(*8*[[0, 1]]):
    for i in range(M):
        s = S[i]
        active_swtiches = []
        for switch_n in s:
            active_swtiches += pattern[switch_n]
        if active_swtiches // 2 != p[i]:
            break
        if i == M - 1:
            cnt += 1
print(cnt)