def inpl(): return list(map(int, input().split()))
N, M = inpl()
L = [0]*M
for i in range(M):
    for s in inpl()[1:]:
        L[i] += pow(2, s-1)
P = inpl()
print(sum([sum([bin(L[j]&i).count("1")%2 == P[j] for j in range(M)]) == M for i in range(pow(2, N))]))