N, M = map(int, input().split())
ans = 0
l=[]
for i in range(M):
  l.append(input().split())
p = [int(x) for x in input().split()]
for i in range(2 ** N):
  on = 0
  sw = [int(x) for x in list(bin(i)[2:].zfill(N))]
  for j in range(M):
    s = 0
    for k in range(1,int(l[j][0])+1):
      s += int(sw[N - k])
    if s % 2 == p[j]:
      on += 1
  if on == M:
    ans += 1
print(ans)