n, m = map(int, input().split())

sss = [[] for i in range(m)]

for i in range(m):
  ss = list(map(int, input().split()))
  ss = ss[1:]
  sss[i] = ss
#print(sss)

ps = list(map(int, input().split()))

ans = 0
for i in range(2**n):
  s = [0]*n
  for j in range(n):
    if ((i>>j) & 1):
      s[j] = 1
  for a in range(m):
    sum_ = 0
    for b in sss[a]:
      sum_ += s[b-1]
    if sum_%2 !=  ps[a]:
      break
  else:
    ans += 1
    print(s)

print(ans)
      