import numpy as np
N, M = map(int, input().split())
taiou = np.zeros((N,M))
for i in range(M):
    val =  input().split()
    for j in range(int(val[0])):
        v = int(val[j+1])
        taiou[v-1][i] = 1
p = np.array([int(v) for v in input().split()])
cnt = 0
for val in range(2**N):
    v = taiou*np.array([[int(i)] for i in bin(val)[2:].zfill(N)])
    if np.sum(np.sum(v,axis=0)%2==p)==0:
        cnt+=1
    
print(cnt)