import numpy as np

N, M = [int(i) for i in input().split()]
k = [0]*M
s = []
for i in range(M):
    tmp = list(map(int, input().split()))

    k[i] = tmp[0]
    s.append(tmp[1:])
p = [int(i) for i in input().split()]

answer = 0
for i in range(N ** 2):
    flag = 1 # 1: 全部点灯
    for j in range(M):
        count = 0
        need = s[j]
        for k in need:
            if ((i >> k-1) & 1):
                count += 1
        if np.mod(count, 2) != p[j]:
            flag = 0
    if flag == 1:
        answer += 1

print(answer)