import numpy as np

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

S = np.zeros((M,N),dtype=np.int64)
for m in range(M):
    tokens = input().split()
    K = int(tokens[0])
    for k in range(K):
        s = int(tokens[1+k])
        S[m,s-1] = 1 # s is 1-origin

p = [int(tk) for tk in input().split()]

ans = 0
for bits in range(1<<N):
	x = np.array([(bits>>b)&1 for b in range(N)],dtype=np.int64)
	y = S@x
	#print(y)
	for m in range(M):
		if (y[m]&1) != p[m]:
			break  
	else:
		ans += 1

print(ans)
