n, m = map(int, input().split())
k = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
print(sum(all(sum((b >> (j - 1)) & 1 for j in k[i]) % 2 == p[i] for i in range(m)) for b in range(2 ** n)))