N,M=map(int,input().split())
List = []
for i in range(M):
  L=list(map(int,input().split()))
  List.append(L)

on = list(map(int,input().split()))
  
n = N
anscnt = 0
arr = [0 for i in range(N+1)]

for i in range(2 ** n):
  arr = [0 for i in range(N+1)]
  for j in range(n):  # このループが一番のポイント
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      arr[j+1] = 1
  ok = 1

  for k in range(M):
    a = List[k][0]
    cnt = 0
    for l in range(1,a+1):
      if arr[ List[k][l] ] == 1:
        cnt += 1
    if cnt%2 == on[k]:
      ok = 1
    else:
      ok = 0
  if ok == 1:
    anscnt += 1
      
print(int(anscnt/2))