import numpy as np
import itertools
n,m = map(int, input().split())
sw = [[int(i) - 1 for i in input().split()] for _ in range(m)]
p = np.array([int(i) for i in input().split()])
x = np.full_like(p, -1)

s_l = itertools.product(np.array([True,False]), repeat = n)
ans = 0
for si in s_l:
    si = np.array(si)
    for mi in range(m):
        x[mi] = si[sw[mi][1:]].sum() % 2
    if np.all(p == x):
        ans += 1
print(ans) import numpy as np numpy import itertools itertools n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m [int(i) - 1 for i in input().split()] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [int(i) - 1 for i in input().split()] sw = [[int(i) - 1 for i in input().split()] for _ in range(m)] sw [[int(i) - 1 for i in input().split()] for _ in range(m)] int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i p = np.array([int(i) for i in input().split()]) p np.array([int(i) for i in input().split()]) np.array np array [int(i) for i in input().split()] x = np.full_like(p, -1) x np.full_like(p, -1) np.full_like np full_like p -1 s_l = itertools.product(np.array([True,False]), repeat = n) s_l itertools.product(np.array([True,False]), repeat = n) itertools.product itertools product np.array([True,False]) np.array np array [True,False] True False repeat = n repeat n ans = 0 ans 0 for si in s_l:
    si = np.array(si)
    for mi in range(m):
        x[mi] = si[sw[mi][1:]].sum() % 2
    if np.all(p == x):
        ans += 1 si s_l si = np.array(si) si np.array(si) np.array np array si for mi in range(m):
        x[mi] = si[sw[mi][1:]].sum() % 2
     mi range(m) range m x[mi] = si[sw[mi][1:]].sum() % 2 x[mi] x mi si[sw[mi][1:]].sum() % 2 si[sw[mi][1:]].sum() [sw[mi][1:]].sum [sw[mi][1:]] si sw[mi][1:] [mi] sw mi 1: 1 sum 2 if np.all(p == x):
        ans += 1 np.all(p == x) np.all np all p == x p x ans += 1 ans 1 print(ans) print ans m = map(int, input().split()) map(int, input().split()) m si = np.array(si) np.array(si) si p = np.array([int(i) for i in input().split()]) np.array([int(i) for i in input().split()]) p n,m = map(int, input().split()) map(int, input().split()) n ans += 1 1 ans sw = [[int(i) - 1 for i in input().split()] for _ in range(m)] [[int(i) - 1 for i in input().split()] for _ in range(m)] sw x = np.full_like(p, -1) np.full_like(p, -1) x s_l = itertools.product(np.array([True,False]), repeat = n) itertools.product(np.array([True,False]), repeat = n) s_l ans = 0 0 ans
import numpy as np
import itertools
n,m = map(int, input().split())
sw = [[int(i) - 1 for i in input().split()] for _ in range(m)]
p = np.array([int(i) for i in input().split()])
x = np.full_like(p, -1)

s_l = itertools.product(np.array([True,False]), repeat = n)
ans = 0
for si in s_l:
    si = np.array(si)
    for mi in range(m):
        x[mi] = si[sw[mi][1:]].sum() % 2
    if np.all(p == x):
        ans += 1
print(ans)