import sys
import itertools
input = sys.stdin.readline

n, m = map(int, input().split())
k, s = [0]*m, [0]*m
for i in range(m):
    k[i], *s[i] = map(int, input().split())

p = list(map(int, input().split()))
ans = 0
state = [i for i in itertools.product((0, 1), repeat=n)]

for case in state:
    sum = 0
    flag = True
    for i in range(m):  # 電球iにおいて
        for j in s[i]:
            sum += case[j-1]
        if sum % 2 != p[i]:
            flag = False
        if not flag:  # 電球消えてたら次のケースに移る
            break
    if flag:
        ans += 1

print(ans)
