import sys
N,M =map(int, input().split())
q = list()

for i in range(M):
  q.append(list(map(int, input().split()))) #q[0]はqのlength
p = list(map(int, input().split())) #スイッチの偶奇正解を示す

ans = 0

for s in range(2**N):  #sは各スイッチ
  judge = True
  for i in range(M):
    cnt = 0
    for j in range(1, len(q[i])): #range(1,x)は2番目から(K+1)-1番目まで
      w = q[i][j] #i番目のスイッチ,j番目の電球
      if s >> (w-1) & 1 == 1: # 右シフト
        cnt += 1
    if cnt % 2 != p[i]:
      judge = False
  if judge:
    ans += 1
print(ans) import sys sys N,M =map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M q = list() q list() list for i in range(M):
  q.append(list(map(int, input().split()))) #q[0]はqのlength i range(M) range M q.append(list(map(int, input().split()))) q.append q append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for s in range(2**N):  #sは各スイッチ
  judge = True
  for i in range(M):
    cnt = 0
    for j in range(1, len(q[i])): #range(1,x)は2番目から(K+1)-1番目まで
      w = q[i][j] #i番目のスイッチ,j番目の電球
      if s >> (w-1) & 1 == 1: # 右シフト
        cnt += 1
    if cnt % 2 != p[i]:
      judge = False
  if judge:
    ans += 1 s range(2**N) range 2**N 2 N judge = True judge True for i in range(M):
    cnt = 0
    for j in range(1, len(q[i])): #range(1,x)は2番目から(K+1)-1番目まで
      w = q[i][j] #i番目のスイッチ,j番目の電球
      if s >> (w-1) & 1 == 1: # 右シフト
        cnt += 1
    if cnt % 2 != p[i]:
      judge = False
   i range(M) range M cnt = 0 cnt 0 for j in range(1, len(q[i])): #range(1,x)は2番目から(K+1)-1番目まで
      w = q[i][j] #i番目のスイッチ,j番目の電球
      if s >> (w-1) & 1 == 1: # 右シフト
        cnt += 1
     j range(1, len(q[i])) range 1 len(q[i]) len q[i] q i w = q[i][j] w q[i][j] [i] q i j if s >> (w-1) & 1 == 1: # 右シフト
        cnt += 1
     s >> (w-1) & 1 == 1 s >> (w-1) & 1 s >> (w-1) s w-1 w 1 1 1 cnt += 1 cnt 1 if cnt % 2 != p[i]:
      judge = False
   cnt % 2 != p[i] cnt % 2 cnt 2 p[i] p i judge = False judge False if judge:
    ans += 1 judge ans += 1 ans 1 print(ans) print ans N,M =map(int, input().split()) map(int, input().split()) N cnt += 1 1 cnt ans += 1 1 ans p = list(map(int, input().split())) list(map(int, input().split())) p w = q[i][j] q[i][j] w q = list() list() q ans = 0 0 ans cnt = 0 0 cnt judge = False False judge M =map(int, input().split()) map(int, input().split()) M judge = True True judge
import sys
N,M =map(int, input().split())
q = list()

for i in range(M):
  q.append(list(map(int, input().split()))) #q[0]はqのlength
p = list(map(int, input().split())) #スイッチの偶奇正解を示す

ans = 0

for s in range(2**N):  #sは各スイッチ
  judge = True
  for i in range(M):
    cnt = 0
    for j in range(1, len(q[i])): #range(1,x)は2番目から(K+1)-1番目まで
      w = q[i][j] #i番目のスイッチ,j番目の電球
      if s >> (w-1) & 1 == 1: # 右シフト
        cnt += 1
    if cnt % 2 != p[i]:
      judge = False
  if judge:
    ans += 1
print(ans)