n,m = map(int,input().split())
lis = []
for i in range(m):
  l = list(map(int,input().split()))
  l.remove(l[0])
  lis.append(l)
ch = list(map(int,input().split()))
ans = 0
for i in range(2 ** n):
  key = 1
  s = str(format(i,"b").zfill(n))
  num = 0
  for j in range(m):
    for nu in lis[j]:
      if s[nu-1] == "1":
        num += 1
    if num % 2 != ch[j]:
      key = 0
  if key == 1:
    ans += 1

print(ans)