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

import numpy as np
n_pattern = 2**N - 1
form = '0{0}b'.format(N)
ans = 0
from operator import itemgetter
for i in range(1, n_pattern+1):
    state = str(format(i, form))
    counter = 0
    for j,k in enumerate(switch_idx):
        if (itemgetter(*(np.array(k)-1))(state).count('1') % 2) == p[j]:
            counter += 1
        if len(switch_idx) == counter:
            ans += 1

print(ans)