n,m=list(map(int,input().split()))

s=eval('list(map(int,input().split()[1:])),'*m)

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

a=0

r=range

for i in r(1<<n):

 c=[0]*m

 for j in r(n):

  for k in r(m):c[k]+=i>>j&1and j+1in s[k]

 a+=all(j==i%2for i,j in zip(c,p))

print(a)
I=lambda:list(map(int,input().split()))

n,m=I()

s=eval('I(),'*m)

p=I()

a=0

r=range

for i in r(1<<n):

 c=[0]*m

 for j in r(n):

  for k in r(m):c[k]+=i>>j&1and j+1in s[k][1:]

 a+=all(j==i%2for i,j in zip(c,p))

print(a)
n, m = list(map(int, input().split()))
s = eval("list(map(int,input().split()[1:]))," * m)
(*p,) = list(map(int, input().split()))
a = 0
r = range
for i in r(1 << n):
    c = [0] * m
    for j in r(n):
        for k in r(m):
            c[k] += i >> j & 1 and j + 1 in s[k]
    a += all(j == i % 2 for i, j in zip(c, p))
print(a)

I = lambda: list(map(int, input().split()))
n, m = I()
s = eval("I()," * m)
p = I()
a = 0
r = range
for i in r(1 << n):
    c = [0] * m
    for j in r(n):
        for k in r(m):
            c[k] += i >> j & 1 and j + 1 in s[k][1:]
    a += all(j == i % 2 for i, j in zip(c, p))
print(a)

-n, m = list(map(int, input().split())) -s = eval("list(map(int,input().split()[1:]))," * m) -(*p,) = list(map(int, input().split())) +I = lambda: list(map(int, input().split())) +n, m = I() +s = eval("I()," * m) +p = I() -            c[k] += i >> j & 1 and j + 1 in s[k] +            c[k] += i >> j & 1 and j + 1 in s[k][1:]