n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
t = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  bit = [i>>j & 1 for j in range(n)]
  for k,x in enumerate(s):
    if t[k] != sum([bit[y-1] for y in x[1:]])%2:
      break
  else:
    ans += 1
print(ans)
