n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
a=[bin(j)[2:].zfill(n) for j in range(2**n)]
ans=0
for jj in range(2**n):
  b=0
  for i in range(m):
    num=0
    for ii in range(1,s[i][0]+1):
      num+=int(a[jj][s[i][ii]-1])
    if num%2!=p[i]:
      b+=1
  if b==0:
    ans+=1
print(ans)