n,m=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
c=0
for _ in range(2**n):
  s=format(_,'0{}b'.format(n))
  f=1
  for i in range(m):
    a=0
    for j in range(1,k[i][0]+1):
      a+=int(s[k[i][j]-1])
    if a%2!=p[i]:
      f=0
      break
  if f:
    c+=1
print(c)