n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:] for i in range(m)]
t=list(map(int,input().split()))


count=0
pattern=[]
for j in range(2**n):
  for k in range(m):
    switch=0
    for p in range(n):
      if (j>>p)&1 and p+1 in s[k]:
        switch+=1
    if switch%2!=t[k]:
      break
  else:
    count+=1
print(count)
