from itertools import combinations

N,M = map(int,input().split())

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

P = list(map(int,input().split()))

ans = 0
B = []
for i in range(1,N+1) :
    B.append(i)
for i in range(1,N+1) :
    A = list(combinations(B,i))
    
    for a in A :
        
        for j in range(M) :
            cnt = 0
            for l in L[j][1:] :
                if l in a :
                    cnt += 1
            if (cnt%2) != P[j] :
                break
        else :
            ans += 1
print(ans)
            