import itertools
n, m = map(int, input().split())
ks = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
switch = [i for i in range(n)]
c = 0
for i in range(2**n):
  li = []
  flag = False
  for j in range(m):
    if ((i>>j)&1):
      li.append(j+1)
  for j in range(m):
    s = set(li)
    ss = set(ks[j])
    s = s & ss
    if len(s) % 2 == p[j]:
      flag = True
    else:
      flag = False
      break
  if flag:
    c += 1
print(c)
