n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
count = 0

for i in range(2**n):
  SUMLIST = []
  SUM = 0
  check = 0
  l = [0]*n
  for j in range(n):
    if ((i >> j)&1):
      l[n-j-1] = 1
  
  for switch in ks:
    for each in switch[1:]:
      SUM += (l[each-1])
    SUMLIST.append(SUM)
   
  for i in range(m):
    if SUMLIST[i]%2 == p[i]:
      check += 1
      
  if check == m:
    count += 1

print(count)