N, M = map(int,input().split())
KS = [list(map(int,input().split())) for i in range(M)]
P = list(map(int,input().split()))

ans = 0
for i in range(2**N):
  switch = []
  for j in range(N):
    switch.append((i >> j) & 1)
  lights = 0
  connect = 0
  for u in range(M):
    for v in range(KS[u][0]):
      if switch[KS[u][v+1]-1] == True:
        connect += 1
    if connect % 2 == P[u]:
      lights += 1
  if lights == M:
    ans += 1
    
print(ans)

    

