from itertools import product

n, m = map(int, input().split())
k = []
s = []
for _ in range(m):
    a, *b = map(int, input().split())
    k.append(a)
    s.append(b)
p = list(map(int, input().split()))
print(sum(all(sum(i[b - 1] for b in a) % 2 == x for a, x in zip(s, p)) for i in product((0, 1), repeat=n))) from itertools import product n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m k = [] k [] s = [] s [] for _ in range(m):
    a, *b = map(int, input().split())
    k.append(a)
    s.append(b) _ range(m) range m a, *b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split *b b k.append(a) k.append k append a s.append(b) s.append s append b p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split print(sum(all(sum(i[b - 1] for b in a) % 2 == x for a, x in zip(s, p)) for i in product((0, 1), repeat=n))) print sum(all(sum(i[b - 1] for b in a) % 2 == x for a, x in zip(s, p)) for i in product((0, 1), repeat=n)) sum all(sum(i[b - 1] for b in a) % 2 == x for a, x in zip(s, p)) all sum(i[b - 1] for b in a) % 2 == x sum(i[b - 1] for b in a) % 2 sum(i[b - 1] for b in a) sum i[b - 1] i b - 1 b 1 2 x m = map(int, input().split()) map(int, input().split()) m a, *b = map(int, input().split()) map(int, input().split()) a n, m = map(int, input().split()) map(int, input().split()) n p = list(map(int, input().split())) list(map(int, input().split())) p k = [] [] k s = [] [] s
from itertools import product

n, m = map(int, input().split())
k = []
s = []
for _ in range(m):
    a, *b = map(int, input().split())
    k.append(a)
    s.append(b)
p = list(map(int, input().split()))
print(sum(all(sum(i[b - 1] for b in a) % 2 == x for a, x in zip(s, p)) for i in product((0, 1), repeat=n)))