N,M = map(int,input().split())
Switch = [0] * N
for i in range(M):
  k,*S = map(int,input().split())
  for s in S:
    s -= 1
    Switch[s] |= (1 <<i)
#print(Switch)
P = list(map(int,input().split()))
p = 0
for i in range(len(P)):
  p |= (P[i] <<i)
#print(p)

ans = 0
for i in range(2 ** N):
  light = 0
  for j in range(M):
    if (i >>j) & 1 == 1:
      light ^= Switch[j]
  if light == p:
    ans += 1
print(ans)
