#C
n,m = map(int,input().split())
denkyu = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    denkyu.append(tmp)   
p = list(map(int,input().split()))

#bit全探索？
import itertools
switch = list(itertools.product([0,1],repeat=n))
cnt = 0

for i in switch:
    gokei = 0
    flg = True
    for j in range(m):
        for k in range(1,len(denkyu[j])):
            gokei += i[denkyu[j][k]-1] 
            
        if gokei % 2 != p[j]:
            flg = False
            
    if flg:
        cnt += 1
        
print(cnt)