N,M=map(int,input().split())
s=[list(map(int,input().split())) for i in range(M)]
p=list(map(int,input().split()))
ans=0
for i in range(2**N):
  ptn=bin(i)[2:].rjust(N,'0')
  light=True
  for j in range(M):
    tmp=0
    for n in range(1,s[j][0]+1):
      if ptn[s[j][n]-1]=='1':
        tmp+=1
      if tmp%2!=p[j]:
        light=False
    if light==True:
      ans+=1
print(ans)