from itertools import combinations

N, M = map(int, input().strip().split(' '))

cmb = []
for i in range(N):
  cmb.extend(list(combinations(range(N), i + 1)))

A = {i: set() for i in range(N)}

for i in range(M):
  line = [int(i) for i in input().strip().split(' ')]
  for s in line[1:]:
    A[s - 1].add(i)

P = list(map(int, input().strip().split(' ')))

counter = 0
for c in cmb:
  # print(c)
  tmp = [0] * M
  for i in c:
    for j in A[i]:
      tmp[j] = (tmp[j] + 1) % 2
  if tmp == P:
    counter += 1

print(counter)