import numpy as np
N,M  = map(int,input().split())
coeff = np.zeros((M,N))
for i in range(M):
    inputs = list(map(int,input().split()))
    for switch in inputs[1:]:
        coeff[i][switch-1] = 1
onlist = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    vec = [int(num) for num in bin(i)[2:]]
    fill = N - len(vec)
    vec = np.append(np.zeros(fill),np.array(vec))
#     print(vec)
    if sum(onlist == np.matmul(coeff,vec)%2) == M:
        ans +=1
print(ans)