n, m = map(int, input().split())
A = []
for _ in range(m):
  k, *s = map(int, input().split())
  c = 0
  for i in s:
    c += 2**(i-1)
  A.append(c)
P = tuple(map(int, input().split()))
ans = 0
for i in range(2**n):
  f = True
  for j in range(m):
    c = bin(i & A[j]).count("1")
    if c%2 != P[j]:
      f = False
      break
  if f:
    ans += 1
print(ans)