# coding: utf-8
N, M = map(int, input().split())
K, S = [], []
for i in range(M):
    tmp = list(map(int, input().split()))
    K.append(tmp[0])
    S.append(tmp[1:])
P = list(map(int, input().split()))
# print(*K, *S, *P)

ans = [0] * M
for i in range(M):
    total = 0
    for bit in range(2**len(S[i])):
        tmp = 0
        for j in range(len(S[i])):
            if (bit >> j) & 1 == 1:
                tmp += 1
        if tmp % 2 == P[i]:
            total += 1
    ans[i] += total
    if P[i] == 0:
        ans[i] -= 1
    
# print(ans)

answer = 1
for i in range(len(ans)):
    answer *= ans[i]
print(answer)
