N, M = map(int, input().split())
k, s = [[] for _ in range(2)]
for _ in range(M):
    kk, *connected_switches = map(int, input().split())
    k.append(kk)
    s.append(connected_switches)

p = list(map(int, input().split()))

OFF = 0
ON = 1

ans = 0
for i in range(2 ** N):
    ptn = [OFF] * N
    for j in range(N):
        if (i >> j) & 1:
            ptn[len(ptn) - j - 1] = ON

    ON_SW_COUNT_LIST = []  # 各電球に繋がったON状態のスイッチの数リスト
    for connected_switches in s:
        on_sw_cnt = len([1 for sw in connected_switches if ptn[sw - 1] == ON])
        ON_SW_COUNT_LIST.append(on_sw_cnt)

    ans += all([c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)])

print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M [] for _ in range(2) for _ in range(2) _ range(2) range 2 for _ in range(2) [] k, s = [[] for _ in range(2)] k [[] for _ in range(2)] s for _ in range(M):
    kk, *connected_switches = map(int, input().split())
    k.append(kk)
    s.append(connected_switches) _ range(M) range M kk, *connected_switches = map(int, input().split()) kk map(int, input().split()) map int input().split() ().split () input split *connected_switches connected_switches k.append(kk) k.append k append kk s.append(connected_switches) s.append s append connected_switches p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split OFF = 0 OFF 0 ON = 1 ON 1 ans = 0 ans 0 for i in range(2 ** N):
    ptn = [OFF] * N
    for j in range(N):
        if (i >> j) & 1:
            ptn[len(ptn) - j - 1] = ON

    ON_SW_COUNT_LIST = []  # 各電球に繋がったON状態のスイッチの数リスト
    for connected_switches in s:
        on_sw_cnt = len([1 for sw in connected_switches if ptn[sw - 1] == ON])
        ON_SW_COUNT_LIST.append(on_sw_cnt)

    ans += all([c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)]) i range(2 ** N) range 2 ** N 2 N ptn = [OFF] * N ptn [OFF] * N [OFF] OFF N for j in range(N):
        if (i >> j) & 1:
            ptn[len(ptn) - j - 1] = ON

     j range(N) range N if (i >> j) & 1:
            ptn[len(ptn) - j - 1] = ON

     (i >> j) & 1 i >> j i j 1 ptn[len(ptn) - j - 1] = ON ptn[len(ptn) - j - 1] ptn len(ptn) - j - 1 len(ptn) - j len(ptn) len ptn j 1 ON ON_SW_COUNT_LIST = [] ON_SW_COUNT_LIST [] for connected_switches in s:
        on_sw_cnt = len([1 for sw in connected_switches if ptn[sw - 1] == ON])
        ON_SW_COUNT_LIST.append(on_sw_cnt)

     connected_switches s 1 for sw in connected_switches if ptn[sw - 1] == ON for sw in connected_switches if ptn[sw - 1] == ON sw connected_switches ptn[sw - 1] == ON ptn[sw - 1] ptn sw - 1 sw 1 ON if ptn[sw - 1] == ON 1 on_sw_cnt = len([1 for sw in connected_switches if ptn[sw - 1] == ON]) on_sw_cnt len([1 for sw in connected_switches if ptn[sw - 1] == ON]) len [1 for sw in connected_switches if ptn[sw - 1] == ON] ON_SW_COUNT_LIST.append(on_sw_cnt) ON_SW_COUNT_LIST.append ON_SW_COUNT_LIST append on_sw_cnt c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST) for i, c in enumerate(ON_SW_COUNT_LIST) i c enumerate(ON_SW_COUNT_LIST) enumerate ON_SW_COUNT_LIST for i, c in enumerate(ON_SW_COUNT_LIST) c % 2 == p[i] c % 2 c 2 p[i] p i ans += all([c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)]) ans all([c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)]) all [c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)] print(ans) print ans M = map(int, input().split()) map(int, input().split()) M p = list(map(int, input().split())) list(map(int, input().split())) p OFF = 0 0 OFF ptn = [OFF] * N [OFF] * N ptn k, s = [[] for _ in range(2)] [[] for _ in range(2)] k s = [[] for _ in range(2)] [[] for _ in range(2)] s ON = 1 1 ON ans = 0 0 ans N, M = map(int, input().split()) map(int, input().split()) N kk, *connected_switches = map(int, input().split()) map(int, input().split()) kk ans += all([c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)]) all([c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)]) ans ON_SW_COUNT_LIST = [] [] ON_SW_COUNT_LIST on_sw_cnt = len([1 for sw in connected_switches if ptn[sw - 1] == ON]) len([1 for sw in connected_switches if ptn[sw - 1] == ON]) on_sw_cnt
N, M = map(int, input().split())
k, s = [[] for _ in range(2)]
for _ in range(M):
    kk, *connected_switches = map(int, input().split())
    k.append(kk)
    s.append(connected_switches)

p = list(map(int, input().split()))

OFF = 0
ON = 1

ans = 0
for i in range(2 ** N):
    ptn = [OFF] * N
    for j in range(N):
        if (i >> j) & 1:
            ptn[len(ptn) - j - 1] = ON

    ON_SW_COUNT_LIST = []  # 各電球に繋がったON状態のスイッチの数リスト
    for connected_switches in s:
        on_sw_cnt = len([1 for sw in connected_switches if ptn[sw - 1] == ON])
        ON_SW_COUNT_LIST.append(on_sw_cnt)

    ans += all([c % 2 == p[i] for i, c in enumerate(ON_SW_COUNT_LIST)])

print(ans)
