import copy

L=[]

def check(M,p,tmp):
  n_ok=0
  sum=0
  for i in range(len(L)):
    for l in L[i]:
      sum+= 1 if tmp[l-1]==1 else 0
    if sum%2==p[i]:
      n_ok+=1
      
  if n_ok==M:
    return 1
  else:
    return 0

def rc(N,M,p,i,tmp):
  if i==N-1:
    return check(M,p,tmp)
  else:
    t1=copy.copy(tmp)
    t2=copy.copy(tmp)
    t1.append(0)
    t2.append(1)
    return rc(N,M,p,i+1,t1)+rc(N,M,p,i+1,t2)

N, M = map(int, input().split())
for _ in range(M):
    tmp = list(map(int,input().split()))
    L.append(tmp[1:])
p=list(map(int,input().split()))
S=[0 for _ in range(N)]

print(rc(N,M,p,-1,[]))