N,M = map(int,input().split())
L = [[] for _ in range(M)]
for i in range(M):
  L[i] = list(map(int,input().split()))
  L[i].remove(L[i][0])
P = list(map(int,input().split()))
Cand = []
for i in range(2**N):
  res = []
  for j in range(N):
    if ((i>>j) & 1):
      res.append(1)
    else:
      res.append(0)
  Cand.append(res) 
res = 0
for i in range(2**N):
    key = 0
    loop = 0
    for j in range(M):
        loop = 1
        if P[j] == 0:
            Even_counter = 0
            for el in L[j]:
                if Cand[i][el-1] == 1:
                    Even_counter += 1
            if Even_counter % 2 != 1:
                key = 1
                break
        if P[j] == 1:
            Od_counter = 0
            for el in L[j]:
                if Cand[i][el-1] == 1:
                    Od_counter += 1
            if Od_counter % 2 != 1:
                key = 1
                break           
        if key == 0 and j == M-1 and loop == 1:
            res += 1    
print(res)