#!/usr/bin/env python3
n, m = map(int, input().split())
s = [None] * m
for i in range(m):
    k, *s[i] = map(lambda x: int(x) - 1, input().split())
p = list(map(int, input().split()))
ans = 0
for b in range(1 << n):
    f = True
    for i in range(m):
        cnt = sum(b >> x & 1 for x in s[i])
        f &= (cnt % 2 == p[i])
    ans += f
print(ans)

