n, m = map(int,input().split())
X = []
for _ in range(m):
  k, *A = list(map(int,input().split()))
  b = 0
  for a in A:
    b += 1 << (a-1)
  X.append(b)
P = list(map(int,input().split()))

ans = 0
for i in range(1<<n):
  for x, p in zip(X,P):
    y = i & x
    c = bin(y).count("1") % 2
    if c != p:
      break
  else:
    ans += 1
print(ans)