from itertools import product
n, m = map(int, input().split())
switch = []
for _ in range(m):
    k, *s = map(lambda x: int(x)-1, input().split())
    switch.append(s)
p = map(int, input().split())

ans = 0
for subset in product((0, 1), n):
    for j in range(m):
        on_cnt = sum(subset[s] for s in switch[j])
        if on_cnt % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)
