import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

ans = 0
N,M = map(int,readline().split())
L = []

for i in range(M):
    k,*S = map(int,readline().split())
    L.append(S)

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

A = list(itertools.product([0,1],repeat=N))

for i in A:
    sw = [False] * N
    for j in range(M):
        count = 0
        for k in L[j]:
            count += i[k-1]

        if count % 2 == P[j]:
            sw[j] = True
            
    if sum(sw) == N:
        ans += 1
print(ans)