# -*- coding: utf-8 -*-

N, M = map(int, input().split())
lights = [map(int, input().split()[1:]) for i in range(M)]
p = map(int, input().split())

combi = 0
for i in range(1<<N):
    flag = True
    for j, switch in enumerate(lights):
        if sum([1 for s in switch if (i>>(s-1)) & 1 == 1])%2 != p[j]:
            flag = False
            break
    if flag:
        combi += 1

print(combi)