import numpy as np
import itertools
N,M = map(int,input().split())

X = np.zeros((M,N))
for m in range(M):
  tmp = list(map(int,input().split()))
  for n in tmp[1:]:
    X[m-1,n-1] = 1
p = list(map(int,input().split()))

cnt = 0
for pattern in itertools.product([0,1], repeat=N):
  a = np.sum(X[:,np.array(pattern)==1],axis=1)
  if p == (a%2).tolist():
    cnt += 1
print(cnt)
  