import itertools
N, M = map(int, input().split())
K = [list(map(int, input().split())) for i in range(M)]
P = list(map(int, input().split()))

result = 0
sij = [i + 1 for i in range(N)]
for m in sij:
    c = itertools.combinations(sij, m)
    for kumi in c:
        flag = True
        for i in range(M):
            # ついてる個数
            kosuu = len(set(K[i][1:]) & set(kumi))
            if kosuu == 0:
                continue
            if kosuu % 2 != P[i]:
                flag = False
        if flag is True:
            result += 1
print(result)
