N, M = map(int, input().split())
S = []
for i in range(M):
    k = list(map(int, input().split()))
    S.append(k[1:])
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
    a = 0
    for j in range(M):
        t = 0
        for s in S[j]:
            t += (i >> (s - 1)) & 1
        if t % 2 == P[j]: a += 1
    if a == M: ans += 1
print(ans)
