# -*- coding: utf-8 -*-
import itertools

import numpy as np


# 読み込み
n, m = map(int, input().split())
swicthes = np.zeros((m, n), dtype=int)

for i in range(m):
    _, *s = map(lambda x: int(x) - 1, input().split())
    swicthes[i, np.array(s, dtype=int)] = 1

l = list(map(int, input().split()))
p = np.array(l, dtype=int)

# bit全探索
count = 0
for on in itertools.product([0, 1], repeat=n):
    _on = np.array(on, dtype=int)
    status = np.sum(swicthes * _on, axis=1) % 2
    if np.sum(p == status) == m:
        # 全ての電球が点灯している
        count += 1

print(count) import itertools itertools import numpy as np numpy n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m swicthes = np.zeros((m, n), dtype=int) swicthes np.zeros((m, n), dtype=int) np.zeros np zeros (m, n) m n dtype=int dtype int for i in range(m):
    _, *s = map(lambda x: int(x) - 1, input().split())
    swicthes[i, np.array(s, dtype=int)] = 1 i range(m) range m _, *s = map(lambda x: int(x) - 1, input().split()) _ map(lambda x: int(x) - 1, input().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x input().split() ().split () input split *s s swicthes[i, np.array(s, dtype=int)] = 1 swicthes[i, np.array(s, dtype=int)] swicthes i 1 l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split p = np.array(l, dtype=int) p np.array(l, dtype=int) np.array np array l dtype=int dtype int count = 0 count 0 for on in itertools.product([0, 1], repeat=n):
    _on = np.array(on, dtype=int)
    status = np.sum(swicthes * _on, axis=1) % 2
    if np.sum(p == status) == m:
        # 全ての電球が点灯している
        count += 1 on itertools.product([0, 1], repeat=n) itertools.product itertools product [0, 1] 0 1 repeat=n repeat n _on = np.array(on, dtype=int) _on np.array(on, dtype=int) np.array np array on dtype=int dtype int status = np.sum(swicthes * _on, axis=1) % 2 status np.sum(swicthes * _on, axis=1) % 2 np.sum(swicthes * _on, axis=1) np.sum np sum swicthes * _on swicthes _on axis=1 axis 1 2 if np.sum(p == status) == m:
        # 全ての電球が点灯している
        count += 1 np.sum(p == status) == m np.sum(p == status) np.sum np sum p == status p status m count += 1 count 1 print(count) print count m = map(int, input().split()) map(int, input().split()) m swicthes = np.zeros((m, n), dtype=int) np.zeros((m, n), dtype=int) swicthes count = 0 0 count p = np.array(l, dtype=int) np.array(l, dtype=int) p count += 1 1 count l = list(map(int, input().split())) list(map(int, input().split())) l n, m = map(int, input().split()) map(int, input().split()) n _, *s = map(lambda x: int(x) - 1, input().split()) map(lambda x: int(x) - 1, input().split()) _ _on = np.array(on, dtype=int) np.array(on, dtype=int) _on status = np.sum(swicthes * _on, axis=1) % 2 np.sum(swicthes * _on, axis=1) % 2 status
# -*- coding: utf-8 -*-
import itertools

import numpy as np


# 読み込み
n, m = map(int, input().split())
swicthes = np.zeros((m, n), dtype=int)

for i in range(m):
    _, *s = map(lambda x: int(x) - 1, input().split())
    swicthes[i, np.array(s, dtype=int)] = 1

l = list(map(int, input().split()))
p = np.array(l, dtype=int)

# bit全探索
count = 0
for on in itertools.product([0, 1], repeat=n):
    _on = np.array(on, dtype=int)
    status = np.sum(swicthes * _on, axis=1) % 2
    if np.sum(p == status) == m:
        # 全ての電球が点灯している
        count += 1

print(count)
