import sys
import numpy as np
import itertools

fin = sys.stdin.readline
N, M = [int(elem) for elem in fin().split()]
conditions = [[int(elem)-1 for elem in fin().split()] for _ in range(M)]
p_list = [int(elem) for elem in fin().split()]

count = 0
perm_list = list(range(0, N))
for r in range(1, len(perm_list)+1):
    for each_iter in itertools.combinations(perm_list, r):
        each_switchs = np.zeros((N))
        each_iter = list(each_iter)
        each_switchs[each_iter] = 1
        flag = 0
        for i, each_condition in enumerate(conditions):
            each_sum = each_switchs[each_condition[1:]]
            if np.sum(each_sum) % 2 != p_list[i]:
                flag = 1
        if flag == 0:
            count += 1

print(count)
