N,M = map(int,input().split())
K = [list(map(int,input().split()))[1:] for i in range(M)]
P = list(map(int,input().split()))
ans = 0
for i in range(0,2 ** N):#0 ~ 3:00 ~ 11
  S = [0] * M
  for j in range(M):
    for k in range(N):
      if (i >> k & 1) and k + 1 in K[j]:
        S[j] += 1
  S = [i % 2 for i in S]
  if S == P:
    ans += 1
print(ans)