from itertools import product

n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
print(sum(all(sum(i[b - 1] for b in a[1:]) % 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 list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s = [list(map(int, input().split())) for _ in range(m)] s [list(map(int, input().split())) for _ in range(m)] 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[1:]) % 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[1:]) % 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[1:]) % 2 == x for a, x in zip(s, p)) all sum(i[b - 1] for b in a[1:]) % 2 == x sum(i[b - 1] for b in a[1:]) % 2 sum(i[b - 1] for b in a[1:]) sum i[b - 1] i b - 1 b 1 2 x m = map(int, input().split()) map(int, input().split()) m s = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] s p = list(map(int, input().split())) list(map(int, input().split())) p n, m = map(int, input().split()) map(int, input().split()) n
from itertools import product

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