# -*- coding: utf-8 -*-
# 標準入力を取得
N, M = list(map(int, input().split()))
k, s = [], []
for m in range(M):
    l = list(map(int, input().split()))
    k.append(l[0])
    s.append(l[1:])
p = list(map(int, input().split()))

# 求解処理
ans = 0
for bit in range(1 << N):
    is_light_on = True
    for m in range(M):
        on_count = 0
        for s_i in s[m]:
            if ((bit >> (s_i - 1)) & 1):
                on_count += 1
        if on_count % 2 != p[m]:
            is_light_on = False
            break
    if is_light_on:
        ans += 1

# 結果出力
print(ans) N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M k, s = [], [] k [] s [] for m in range(M):
    l = list(map(int, input().split()))
    k.append(l[0])
    s.append(l[1:]) m range(M) range M l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k.append(l[0]) k.append k append l[0] l 0 s.append(l[1:]) s.append s append l[1:] l 1: 1 p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for bit in range(1 << N):
    is_light_on = True
    for m in range(M):
        on_count = 0
        for s_i in s[m]:
            if ((bit >> (s_i - 1)) & 1):
                on_count += 1
        if on_count % 2 != p[m]:
            is_light_on = False
            break
    if is_light_on:
        ans += 1

# 結果出力 bit range(1 << N) range 1 << N 1 N is_light_on = True is_light_on True for m in range(M):
        on_count = 0
        for s_i in s[m]:
            if ((bit >> (s_i - 1)) & 1):
                on_count += 1
        if on_count % 2 != p[m]:
            is_light_on = False
            break
     m range(M) range M on_count = 0 on_count 0 for s_i in s[m]:
            if ((bit >> (s_i - 1)) & 1):
                on_count += 1
         s_i s[m] s m if ((bit >> (s_i - 1)) & 1):
                on_count += 1
         (bit >> (s_i - 1)) & 1 bit >> (s_i - 1) bit s_i - 1 s_i 1 1 on_count += 1 on_count 1 if on_count % 2 != p[m]:
            is_light_on = False
            break
     on_count % 2 != p[m] on_count % 2 on_count 2 p[m] p m is_light_on = False is_light_on False break if is_light_on:
        ans += 1

# 結果出力 is_light_on ans += 1 ans 1 print(ans) print ans on_count = 0 0 on_count N, M = list(map(int, input().split())) list(map(int, input().split())) N l = list(map(int, input().split())) list(map(int, input().split())) l s = [], [] [] s is_light_on = True True is_light_on ans += 1 1 ans ans = 0 0 ans on_count += 1 1 on_count is_light_on = False False is_light_on M = list(map(int, input().split())) list(map(int, input().split())) M k, s = [], [] [] k p = list(map(int, input().split())) list(map(int, input().split())) p
# -*- coding: utf-8 -*-
# 標準入力を取得
N, M = list(map(int, input().split()))
k, s = [], []
for m in range(M):
    l = list(map(int, input().split()))
    k.append(l[0])
    s.append(l[1:])
p = list(map(int, input().split()))

# 求解処理
ans = 0
for bit in range(1 << N):
    is_light_on = True
    for m in range(M):
        on_count = 0
        for s_i in s[m]:
            if ((bit >> (s_i - 1)) & 1):
                on_count += 1
        if on_count % 2 != p[m]:
            is_light_on = False
            break
    if is_light_on:
        ans += 1

# 結果出力
print(ans)
