# author:  Taichicchi
# created: 16.09.2020 23:07:07

import sys

N, M = map(int, input().split())

k = []
s = []

for i in range(M):
    _k, *_s = map(int, input().split())
    k.append(_k)
    s.append(_s)

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


for i in range(2 ** N):
    sw = [0 for _ in range(N)]
    for j in range(N):
        if i >> j & 1:
            sw[j] = 1

    for m in range(M):
        mod = 0
        for switch in s[m]:
            mod += sw[switch - 1]
        if mod % 2 != p[m]:
            break
    else:
        ans += 1

print(ans) import sys sys N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M k = [] k [] s = [] s [] for i in range(M):
    _k, *_s = map(int, input().split())
    k.append(_k)
    s.append(_s) i range(M) range M _k, *_s = map(int, input().split()) _k map(int, input().split()) map int input().split() ().split () input split *_s _s k.append(_k) k.append k append _k s.append(_s) s.append s append _s 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 i in range(2 ** N):
    sw = [0 for _ in range(N)]
    for j in range(N):
        if i >> j & 1:
            sw[j] = 1

    for m in range(M):
        mod = 0
        for switch in s[m]:
            mod += sw[switch - 1]
        if mod % 2 != p[m]:
            break
    else:
        ans += 1 i range(2 ** N) range 2 ** N 2 N 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 sw = [0 for _ in range(N)] sw [0 for _ in range(N)] for j in range(N):
        if i >> j & 1:
            sw[j] = 1

     j range(N) range N if i >> j & 1:
            sw[j] = 1

     i >> j & 1 i >> j i j 1 sw[j] = 1 sw[j] sw j 1 for m in range(M):
        mod = 0
        for switch in s[m]:
            mod += sw[switch - 1]
        if mod % 2 != p[m]:
            break
    else:
        ans += 1 m range(M) range M mod = 0 mod 0 for switch in s[m]:
            mod += sw[switch - 1]
         switch s[m] s m mod += sw[switch - 1] mod sw[switch - 1] sw switch - 1 switch 1 if mod % 2 != p[m]:
            break
     mod % 2 != p[m] mod % 2 mod 2 p[m] p m break ans += 1 ans 1 print(ans) print ans M = map(int, input().split()) map(int, input().split()) M s = [] [] s sw = [0 for _ in range(N)] [0 for _ in range(N)] sw ans = 0 0 ans _k, *_s = map(int, input().split()) map(int, input().split()) _k mod += sw[switch - 1] sw[switch - 1] mod p = list(map(int, input().split())) list(map(int, input().split())) p mod = 0 0 mod ans += 1 1 ans N, M = map(int, input().split()) map(int, input().split()) N k = [] [] k
# author:  Taichicchi
# created: 16.09.2020 23:07:07

import sys

N, M = map(int, input().split())

k = []
s = []

for i in range(M):
    _k, *_s = map(int, input().split())
    k.append(_k)
    s.append(_s)

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


for i in range(2 ** N):
    sw = [0 for _ in range(N)]
    for j in range(N):
        if i >> j & 1:
            sw[j] = 1

    for m in range(M):
        mod = 0
        for switch in s[m]:
            mod += sw[switch - 1]
        if mod % 2 != p[m]:
            break
    else:
        ans += 1

print(ans)
