N, M = map(int, input().split())
s = [list(map(int, input().spllit())) [1:] for i in range(M)]
p = list(map(int, input().split()))
total = 0
j = 0
for i in range(2 ** N):
  lis = []
  for j in range(N):
    lis.append((i>>j) & 1)
  for k in range(M):
    tmp = 0
    for l in s[k]:
      tmp += lis[l-1]
    if tmp % 2 == p[k]:
      j += 1
  if j == M :
    total += 1
  j = 0
print(total)