n,m=map(int,input().split())
s=eval('list(map(int,input().split()[1:])),'*m)
*p,=map(int,input().split())
a=0
r=range
for i in r(1<<n):
 c=[0]*m
 for j in r(n):
  for k in r(m):c[k]+=i>>j&1and j+1in s[k]
 a+=all(j==i%2for i,j in zip(c,p))
print(a)