N, M = map(int, input().split())
# N:スイッチの数、M：電球の数
s = [[] for _ in range(M)]
for i in range(M):
    temp = list(map(int, input().split()))
    s[i] = temp[1:]
p = list(map(int, input().split()))
ans = 0

# bit全探索
for i in range(2 ** N):
    on = [0 for _ in range(N)]
    for j in range(N): 
        if (i >> j) & 1:
            for k in range(N):
                if j+1 in s[k]:
                    on[k] += 1
    tf = []
    for on_n, p_n in zip(on, p):
        if on_n % 2 == p_n:
            tf.append(True)
        else:
            tf.append(False)
    if all(flg for flg in tf):
        ans += 1

print(ans)
