n,m = map(int,input().split())
s = []
for i in range(m):
  ks = list(map(int,input().split()))
  s.append(ks)
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  flag = True
  for j in range(m):
    count = 0
    for k in range(s[m][0]):
      if i & (1<<(s[m][k+1]-1)): count += 1
    if count%2!=p[j]: flag = False
  if flag==True: ans += 1
print(ans)
