N, M = list(map(int, input().split()))
K = []
S = []
for i in range(M):
    v = list(map(int, input().split()))
    K.append(v[0])
    S.append(v[1:])
P = list(map(int, input().split()))

swi = [[0] * N for _ in range(2**N)]
for i in range(2**N):
    for j in range(N):
        if (i // 2**j) % 2 == 1:
            swi[i][j] = 1

ans = 0
for b in range(2**N):
    done = True
    for i in range(M):
        now = 0
        for k in range(K[i]):
            now += swi[b][k]
        if now % 2 != P[i]:
            done = False
            break
    if done:
        ans += 1

print(ans)
