N, M = map(int,input().split())
each_s = []
for _ in range(M):
  each_s.append(list(map(int,input().split()))[1:])
p = list(map(int,input().split()))
print(each_s)
print(p)

switch = 2**N
answer = 0

for i in range(switch):
  lamp = []
  for j in range(len(each_s)):
    count = 0
    for k in each_s[j]:
      if(bin(i>>k)[-1] == "1"):
        count += 1
    lamp.append(count % 2)
  if lamp == p:
    answer += 1
print(answer)