n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
b=list(map(int,input().split()))
ans=0
for i in range(2**n):
  c=[]
  q=True
  for j in range(n):
    c.append((i>>j)&1)
  for k in range(m):
    p=0
    for l in range(1,a[k][0]+1):
      if c[a[k][l]-1]==1:
        p+=1
    if p%2!=b[k]:
      q=False
  if q:
    ans+=1
print(ans)