n,m=map(int,input().split())
s=[0]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[i][0]
p=list(map(int,input().split()))
count=0
for i in range(2**n):
  for k in range(m):
    temp=0
    for j in range(n):
      if ((i >> j) & 1) and j+1 in s[k]:
        temp=temp+1
    if temp%2!=p[k]:
      break
  else:
    count=count+1
print(count)